<template>
	<!-- title -->
	<view>
		<view v-if="global.board == '调试助手' || global.board == 'ZN-BINLC'">			
			<view class="uni-mx-2 uni-mt-4 flex-row">
				<view class="uni-mx-1">型号:</view>
				<view class="width-3 uni-mr-1" style="position: relative;z-index: 10;">
					<uni-data-select
					      v-model="global.board"
					      :localdata="global.boardList"				      
						  :clear="false"
					></uni-data-select>
				</view>					
			</view>			
		</view>
		<view v-else>
			<view class="flex-center uni-mt-2">
				<view class="flex-center">
					<view class="uni-mx-1">型号:</view>
					<view class="width-3 uni-mr-1" style="position: relative;z-index: 10;">
						<uni-data-select
						      v-model="global.board"
						      :localdata="global.boardList"					      
							  :clear="false"
						></uni-data-select>
					</view>
					<button class="uni-px-4" type="default" size="mini" @click="check('searchBoard')">搜索</button>
				</view>
				<view class="flex-center">
					<view class="flex-center">
						<view class="uni-ml-1">FF</view>
						<switch class="uni-mx-0" style="transform:scale(0.6)" @change="change.deviceID" />
					</view>
					<view class="flex-center">
						<view class="uni-mr-1">ID:</view>
						<view class="uni-mr-1" style="position: relative;z-index: 10;">
							<uni-data-select
							      v-model="serial.slave_id"
							      :localdata="serial.slave_list"						      
								  :clear="false"
							></uni-data-select>
						</view>
					</view>
				</view>			
			</view>
		</view>
	</view>
	<!-- 控制板 -->
	<view>
		<!-- 调试助手 -->
		<view v-if="global.board == '调试助手'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_E" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>	
			<swiper :style="{height: (global.windowHeight-100) + 'px'}" class="background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">				
				<swiper-item>
					<view :style="{height: (global.windowHeight-100) + 'px'}">
						<uni-card margin="5px" spacing="0">							
							<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
							<scroll-view :style="{height: (global.windowHeight-200) + 'px'}" class="device_list" scroll-y scroll-with-animation>
							  <view
							    v-for="(item, index) in blue.devices"
							    :key="index"
							    :data-device-id="item.deviceId"
							    :data-name="item.name || item.localName"
							    @click="bleService.createBLEConnection($event)"
							    class="device_item"
							    hover-class="device_item_hover"
								>
							    <view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
							    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
								</view>
							  </view>
							</scroll-view>
							<view class="flex-center uni-pt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>														
							</view>
						</uni-card>
					</view>
				</swiper-item>
				<swiper-item>
					<view :style="{height: (global.windowHeight-100) + 'px'}">
						<uni-card margin="5px" spacing="0" padding="3px">
							<view class="uni-h6 flex-center">								
								<view class="">
									<uni-data-checkbox  v-model="test.type" :multiple="true" :localdata="test.typeList"/>
								</view>
								<button class="uni-mx-0 uni-px-4" size="mini" @click="testFunc.clearShowData">清空</button>
							</view>
							<view class="flex-center uni-pt-2">								
								<text style="width: 130rpx;">TX: {{test.TXLength}}</text>
								<text style="width: 130rpx;">RX: {{test.RXLength}}</text>
								<uni-data-checkbox  v-model="test.cycle" :multiple="true" :localdata="test.cycleList" @change="change.sendCycle" />
								<uni-easyinput v-model="test.time" @change="change.cycleTime"/>								
							</view>
							<view class="flex-center uni-my-2">
								<uni-easyinput class="uni-ml-4" style="flex: 1;" v-model="test.sendData" placeholder="任意字符" />
								<button class="uni-mx-4" style="background-color: #64bad3;" size="mini" @click="testFunc.writeData">发送</button>
							</view>
							<scroll-view :style="{height: (global.windowHeight-220) + 'px'}" class="device_list" scroll-y scroll-with-animation>
							  <view class="flex-column" v-for="(item,index) in test.log" :key="index">							  	
							  	<view class="text-box" @click="copy(item.value)">
									<text style="color: #64bad3;">{{item.time}}</text>
									<text style="color: #007aff">{{item.name}}</text>
									<text>{{item.value}}</text>
								</view>
							  </view>
							</scroll-view>							
						</uni-card>
					</view>
				</swiper-item>
				<swiper-item>
					<scroll-view :style="{height: (global.windowHeight-100) + 'px'}" scroll-y="true">
						<view class="card">
							<view class="uni-my-4 uni-h5" style="color:#64bad3;">模块信息</view>
							<view class="uni-my-2">
								<text style="color: black;">蓝牙名称：{{blue.deviceName}}</text>								
							</view>
							<view class="uni-my-2">
								<text style="color: black;">物理地址：{{blue.deviceId}}</text>								
							</view>
							<view class="uni-my-2">
								<text style="color: black;">服务特征：{{blue.serviceId}}</text>								
							</view>
							<view class="uni-my-2">
								<text style="color: black;">写入特征：{{blue.characteristicId}}</text>								
							</view>
							<view class="uni-my-2">
								<text style="color: black;">读取特征：{{blue.notifycharacteristicId}}</text>								
							</view>
						</view>
						<view v-if="blue.advertisData == 'aa55'" class="card">							
							<uni-row>
								<uni-col :span="10">
									<view class="uni-my-4 uni-h5" style="color:#64bad3;">通信协议</view>
									<view class="flex-row uni-my-2">
										<text class="uni-mr-2" style="color: black;">波特率:</text>
										<uni-data-select class="width-2" v-model="serial.baudRate_BLE" :localdata="serial.baudRateList_BLE"
											@change="change.baudRate_BLE" :clear="false"></uni-data-select>
									</view>
									<view class="flex-row uni-my-2">
										<text class="uni-mr-2" style="color: black;">停止位:</text>
										<uni-data-select class="width-2" v-model="serial.stopBit_BLE" :localdata="serial.stopBitList_BLE"
											@change="change.stopBit_BLE" :clear="false"></uni-data-select>
									</view>
									<view class="flex-row uni-my-2">
										<text class="uni-mr-2" style="color: black;">校验位:</text>
										<uni-data-select class="width-2" v-model="serial.checkout_BLE" :localdata="serial.checkoutList_BLE"
											@change="change.checkout_BLE" :clear="false"></uni-data-select>
									</view>
								</uni-col>
								<uni-col :span="14">
									<scroll-view class="data_list" scroll-y scroll-with-animation>
										<view class="flex-column" v-for="(item,index) in blue.showData" :key="index">
											<view class="" @click="copy(item.value)">{{item.name+item.value}}</view>
										</view>
									</scroll-view>
								</uni-col>
							</uni-row>							
						</view>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 垃圾分类 -->
		<view v-else-if="global.board == '垃圾分类'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_A" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>		
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
							<scroll-view class="device_list" scroll-y scroll-with-animation>
							  <view
							    v-for="(item, index) in blue.devices"
							    :key="index"
							    :data-device-id="item.deviceId"
							    :data-name="item.name || item.localName"
							    @click="bleService.createBLEConnection($event)"
							    class="device_item"
							    hover-class="device_item_hover"
								>							    
								<view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
							    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
								</view>
							  </view>
							</scroll-view>
							<view class="flex-center uni-mt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>							
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>							
							</view>
						</uni-card>
					</view>
				</swiper-item>
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">
						<uni-card margin="3px" spacing="0" padding="5px">
							<view class="flex-center">
								<view class="uni-h5">重量：</view>
								<view class="card-list-show-m">{{recycle.weight}}</view>
								<view class="uni-h5 uni-ml-3">g</view>
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">投放重量：</view>
								<view class="card-list-show-m">{{recycle.pitchWeight}}</view>
								<view class="uni-h5 uni-ml-3">g</view>
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">温度：</view>
								<view class="card-list-show-m">{{recycle.temperature}}</view>								
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">湿度：</view>
								<view class="card-list-show-m">{{recycle.humidity}}</view>								
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">选中：</view>
								<view class="card-list-show-m">{{recycle.choose}}</view>							
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">光电：</view>
								<view class="card-list-show-m">{{recycle.photoelectric}}</view>							
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">满桶：</view>
								<view class="card-list-show-m">{{recycle.full}}</view>							
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">实时满桶：</view>
								<view class="card-list-show-m">{{recycle.realTimeFull}}</view>							
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">烟雾：</view>
								<view class="card-list-show-m">{{recycle.smoke}}</view>							
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">防夹：</view>
								<view class="card-list-show-m">{{recycle.antiPinch}}</view>							
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">投放状态：</view>
								<view class="card-list-show-m">{{recycle.putState}}</view>							
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">推杆状态：</view>
								<view class="card-list-show-m">{{recycle.pushrod}}</view>
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">脉冲计数：</view>
								<view class="card-list-show-m">{{recycle.di3count}}</view>
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">电机电流：</view>
								<view class="card-list-show-m">{{recycle.current}}</view>
								<view class="uni-h5 uni-ml-3">mA</view>
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">失联状态：</view>
								<view class="card-list-show-m">{{recycle.communication}}</view>
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5">门：</view>
								<view class="card-list-show-m">{{recycle.lock}}</view>							
							</view>
							<view class="flex-center uni-mt-1">
								<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
								<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
								<button type="default" size="mini" @click="check('recycleFunc.stateRead')">读取</button>
							</view>
						</uni-card>
					</scroll-view>
				</swiper-item>
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">
						<uni-card margin="5px" spacing="0px" padding="5px">
							<view class="flex-column">
								<view class="flex-center">
									<view class="uni-h5" style="flex: 1;">温度量程：</view>
									<view class="width-2" style="position: relative;z-index: 1;">
										<uni-data-select
										      v-model="recycle.range"
										      :localdata="recycle.rangeList"										      
											  :clear="false"
										></uni-data-select>
									</view>
								</view>
								<view class="flex-center uni-pt-1">
									<view class="uni-h5" style="flex: 1;">操作：</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_open')">开盖</button>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_close')">关盖</button>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_openDoor')">开门</button>
								</view>
								<view class="flex-center uni-pt-1">
									<view class="uni-h5">感应状态：</view>
									<view class="card-list-show-m">{{recycle.interaction}}</view>
									<button class="uni-mt-1 uni-ml-2" size="mini" @click="check('recycleFunc.interactRead')">感应读取</button>
								</view>
								<view class="flex-center uni-pt-1">
									<view style="flex: 1;"></view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_openSensor')">感应打开</button>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_closeSensor')">感应关闭</button>
								</view>
							</view>
						</uni-card>
						<uni-card margin="5px" spacing="0px" padding="5px">
							<view class="flex-column">								
								<view class="flex-center">
									<view class="uni-h5" style="flex: 1;">电锁：</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_unlock')">打开</button>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_lock')">关闭</button>
								</view>
								<view class="flex-center uni-pt-1">
									<view class="uni-h5" style="flex: 1;">灯光：</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_lightOn')">打开</button>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_lightOff')">关闭</button>
								</view>
							</view>
						</uni-card>
						<uni-card margin="5px" spacing="0px" padding="5px">
							<view class="card">
								<view class="flex-center">
									<view class="uni-h5">校准质量：</view>
									<uni-easyinput  v-model="recycle.weightSet" placeholder="" :clearable="false" :inputBorder="true" type="number" />
									<view class="uni-h5 uni-ml-3">10g</view>
								</view>
								<view class="flex-center uni-pt-1">
									<view class="uni-h5" style="flex: 1;">控制：</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('recycleFunc.clear')">清零</button>
									<button class="uni-mt-1" size="mini" @click="check('recycleFunc.check')">校准</button>
								</view>
							</view>
						</uni-card>
					</scroll-view>
				</swiper-item>
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">
						<uni-card margin="5px" spacing="0" padding="5px">
							<view class="flex-center ">
								<view class="uni-h5">满桶时间(s):</view>
								<uni-easyinput v-model="recycle.warnTime" placeholder="" :clearable="false" :inputBorder="true" type="number" />										
							</view>
							<view class="flex-center uni-mt-1 ">
								<view class="uni-h5">推出时间(s):</view>
								<uni-easyinput v-model="recycle.pushTime" placeholder="" :clearable="false" :inputBorder="true" type="number" />								
							</view>
							<view class="flex-center uni-mt-1 ">
								<view class="uni-h5">保持时间(s):</view>
								<uni-easyinput v-model="recycle.holdTime" placeholder="" :clearable="false" :inputBorder="true" type="number" />									
							</view>
							<view class="flex-center uni-mt-1 ">
								<view class="uni-h5">缩回时间(s):</view>
								<uni-easyinput  v-model="recycle.backTime" placeholder="" :clearable="false" :inputBorder="true" type="number" />										
							</view>
							<view class="flex-center uni-mt-1">
								<view class="uni-h5">堵转电流(mA):</view>
								<uni-easyinput  v-model="recycle.current_max" placeholder="" :clearable="false" :inputBorder="true" type="number"/>										
							</view>
							<view class="flex-center uni-mt-1">
								<view class="uni-h5">增益:</view>
								<uni-easyinput v-model="recycle.gain" placeholder="" :clearable="false" :inputBorder="true" type="text" />
							</view>
							<view class="flex-center uni-mt-1">
								<view class="uni-h5">零偏:</view>
								<uni-easyinput v-model="recycle.offset" placeholder="" :clearable="false" :inputBorder="true" type="text" />
							</view>
							<view class="uni-mt-1">
								<uni-row>
									<uni-col :span="10">
										<view class="flex-center">
											<view class="uni-h5" style="flex: 1;">id：</view>
											<view class="width-1" style="position: relative;z-index: 10;">
												<uni-data-select
												      v-model="recycle.modbusId"
												      :localdata="serial.slave_list"												      
													  :clear="false"
												></uni-data-select>
											</view>
										</view>
									</uni-col>
									<uni-col :span="14">
										<view class="flex-center">
											<view class="uni-h5 uni-ml-5" style="flex: 1">控制板类型：</view>
											<view class="width-1" style="position: relative;z-index: 9;">
												<uni-data-select
												      v-model="recycle.board"
												      :localdata="recycle.boardList"												      
													  :clear="false"
												></uni-data-select>
											</view>
										</view>
									</uni-col>
								</uni-row>
							</view>	
							<uni-data-checkbox width="300rpx" v-model="recycle.config" :multiple="true" :localdata="recycle.configList_GS24" mode="default" @change="recycleFunc.change_Func" />
							<view class="flex-center uni-mt-1">
								<button size="mini" @click="check('recycleFunc.configRead')">读取</button>
								<button size="mini" @click="check('recycleFunc.configWrite')">写入</button>							
								<button size="mini" @click="check('recycleFunc.save')">保存</button>								
							</view>
						</uni-card>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 垃圾分类N -->
		<view v-else-if="global.board == '垃圾分类N'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_G" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>		
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
							<scroll-view class="device_list" scroll-y scroll-with-animation>
							  <view
							    v-for="(item, index) in blue.devices"
							    :key="index"
							    :data-device-id="item.deviceId"
							    :data-name="item.name || item.localName"
							    @click="bleService.createBLEConnection($event)"
							    class="device_item"
							    hover-class="device_item_hover"
								>							    
								<view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
							    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
								</view>
							  </view>
							</scroll-view>
							<view class="flex-center uni-mt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>							
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>							
							</view>
						</uni-card>
					</view>
				</swiper-item>
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">
						<uni-card margin="3px" spacing="0" padding="5px">							
							<uni-row>
								<uni-col :span="8">
									<view class="state-card">
										<view class="flex-row">
											<view class="light-bulb" :class="{'light-red': recycle.choose}"></view>
											<text class="uni-h5">选中</text>
										</view>
										<view class="flex-row">
											<view class="light-bulb" :class="{'light-green': recycle.photoelectric}"></view>
											<text class="uni-h5">光电</text>
										</view>
										<view class="flex-row">
											<view class="light-bulb" :class="{'light-green': recycle.smoke}"></view>
											<text class="uni-h5">烟雾</text>
										</view>
										<view class="flex-row">
											<view class="light-bulb" :class="{'light-green': recycle.antiPinch}"></view>
											<text class="uni-h5">防夹</text>
										</view>
										<view class="flex-row">
											<view class="light-bulb" :class="{'light-green': recycle.lock}"></view>
											<text class="uni-h5">门</text>
										</view>
										<view class="flex-row">
											<view class="light-bulb" :class="{'light-green': recycle.realTimeFull}"></view>
											<text class="uni-h5">实时满桶</text>
										</view>
										<view class="flex-row">
											<view class="light-bulb" :class="{'light-green': recycle.time_input}"></view>
											<text class="uni-h5">定时输入</text>
										</view>	
										<view class="flex-row">
											<view class="light-bulb" :class="{'light-red': recycle.full}"></view>
											<text class="uni-h5">满桶</text>
										</view>
										<view class="flex-row">
											<view class="light-bulb" :class="{'light-red': recycle.limit_P}"></view>
											<text class="uni-h5">正限位</text>
										</view>								
										<view class="flex-row">
											<view class="light-bulb" :class="{'light-red': recycle.limit_R}"></view>
											<text class="uni-h5">反限位</text>
										</view>
									</view>
								</uni-col>							
								<uni-col :span="16">
									<view class="flex-center">
										<view class="uni-h5">重量：</view>
										<view class="card-list-show-m">{{recycle.weight}}</view>
										<view class="uni-h5 uni-ml-3">g</view>
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">投放重量：</view>
										<view class="card-list-show-m">{{recycle.pitchWeight}}</view>
										<view class="uni-h5 uni-ml-3">g</view>
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">温度：</view>
										<view class="card-list-show-m">{{recycle.temperature}}</view>										
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">湿度：</view>
										<view class="card-list-show-m">{{recycle.humidity}}</view>										
									</view>								
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">投放状态：</view>
										<view class="card-list-show-m">{{recycle.putState}}</view>							
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">推杆状态：</view>
										<view class="card-list-show-m">{{recycle.pushrod}}</view>
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">脉冲计数：</view>
										<view class="card-list-show-m">{{recycle.di3count}}</view>
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">电机电流：</view>
										<view class="card-list-show-m">{{recycle.current}}</view>
										<view class="uni-h5 uni-ml-3">mA</view>
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">失联状态：</view>
										<view class="card-list-show-m" :class="recycle.communication?'text-green':'text-red'">{{recycle.communication?'通信正常':'未连接'}}</view>
									</view>
									<view class="flex-center uni-mt-1">
										<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
										<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
										<button type="default" size="mini" @click="check('recycleFunc.stateRead')">读取</button>
									</view>
								</uni-col>
							</uni-row>						
						</uni-card>
						<uni-card margin="5px" spacing="0px" padding="5px">
							<view class="flex-column">								
								<view class="flex-center">
									<view class="uni-h5" style="flex: 1;">操作：</view>
									<button class="uni-mt-1 uni-px-5 uni-mr-2" size="mini" @click="check('Recycle_open')">开盖</button>
									<button class="uni-mt-1 uni-px-5 uni-mr-2" size="mini" @click="check('Recycle_stop')">停止</button>
									<button class="uni-mt-1 uni-px-5 uni-mr-2" size="mini" @click="check('Recycle_close')">关盖</button>
									<button class="uni-mt-1 uni-px-5 uni-mr-2" size="mini" @click="check('Recycle_openUp')">开到上限</button>
									<button class="uni-mt-1 uni-px-5" size="mini" @click="check('Recycle_openDown')">关到下限</button>
								</view>							
								<view class="flex-center">
									<view class="uni-h5">状态：</view>
									<view class="card-list-show-m">{{recycle.interaction}}</view>
									<button class="uni-mt-1 uni-mr-2 uni-px-5" size="mini" @click="check('recycleFunc.interactRead')">感应读取</button>
									<button class="uni-mt-1 uni-mr-2 uni-px-5" size="mini" @click="check('Recycle_openSensor')">感应打开</button>
									<button class="uni-mt-1 uni-px-5" size="mini" @click="check('Recycle_closeSensor')">感应关闭</button>
								</view>							
								<view class="flex-center">
									<view class="uni-h5" style="flex: 1;">电锁：</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_unlock')">打开</button>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_lock')">关闭</button>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_openDoor')">开收运门</button>
								</view>							
								<view class="flex-center">
									<view class="uni-h5" style="flex: 1;">灯光：</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_lightOn')">打开</button>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_lightOff')">关闭</button>
								</view>
								
								<view class="flex-center">
									<view class="uni-h5">校准质量：</view>
									<uni-easyinput  v-model="recycle.weightSet" placeholder="" :clearable="false" :inputBorder="true" type="number" />
									<view class="uni-h5 uni-mx-3">10g</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('recycleFunc.clear')">清零</button>
									<button class="uni-mt-1" size="mini" @click="check('recycleFunc.check')">校准</button>
								</view>
							</view>
						</uni-card>					
					</scroll-view>
				</swiper-item>
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">
						<uni-card margin="3px" spacing="0" padding="5px">
							<uni-data-checkbox width="220rpx"  v-model="recycle.sensorError" :multiple="true" :localdata="recycle.sensorErrorList" mode="default" />
							<view class="divider"></view>
							<uni-row>
								<uni-col :span="10">									
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">IN1：</view>
										<view class="card-list-show-m">{{recycle.inputValue}}</view>							
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">IN2：</view>
										<view class="card-list-show-m">{{recycle.inputValue2}}</view>							
									</view>									
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">AD0：</view>
										<view class="card-list-show-m">{{recycle.temperature}}</view>										
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">AD1：</view>
										<view class="card-list-show-m">{{recycle.humidity}}</view>										
									</view>									
								</uni-col>
								<uni-col :span="14">
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">重量：</view>
										<view class="card-list-show-m">{{recycle.weight}}</view>
										<view class="uni-h5 uni-ml-3">g</view>
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">传感器电流：</view>
										<view class="card-list-show-m">{{recycle.currentWeight}}</view>
										<view class="uni-h5 uni-ml-3">mA</view>
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">S+电压：</view>
										<view class="card-list-show-m">{{recycle.sensorPVoltage}}</view>
										<view class="uni-h5 uni-ml-3">mV</view>
									</view>
									<view class="flex-center uni-pt-1">
										<view class="uni-h5">S-电压：</view>
										<view class="card-list-show-m">{{recycle.sensorNVoltage}}</view>
										<view class="uni-h5 uni-ml-3">mV</view>
									</view>									
								</uni-col>
							</uni-row>
							<view class="flex-center uni-mt-1">
								<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
								<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
								<button type="default" size="mini" @click="check('recycleFunc.state2Read')">读取</button>
							</view>
						</uni-card>
					</scroll-view>
				</swiper-item>
				<!-- <swiper-item>
					<scroll-view class="height-1" scroll-y="true">
						<uni-card margin="5px" spacing="0px" padding="5px">
							<view class="flex-column">								
								<view class="flex-center uni-pt-1">
									<view class="uni-h5" style="flex: 1;">操作：</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_open')">开盖</button>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_stop')">停止</button>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_close')">关盖</button>									
								</view>
								<view class="flex-center uni-pt-1">
									<view class="uni-h5" style="flex: 1;">操作：</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_openUp')">开到上限</button>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_openDown')">关到下限</button>									
								</view>
								<view class="flex-center uni-pt-1">
									<view class="uni-h5">感应状态：</view>
									<view class="card-list-show-m">{{recycle.interaction}}</view>
									<button class="uni-mt-1 uni-ml-2" size="mini" @click="check('recycleFunc.interactRead')">感应读取</button>
								</view>
								<view class="flex-center uni-pt-1">
									<view style="flex: 1;"></view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_openSensor')">感应打开</button>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_closeSensor')">感应关闭</button>
								</view>
							</view>
						</uni-card>
						<uni-card margin="5px" spacing="0px" padding="5px">
							<view class="flex-column">								
								<view class="flex-center">
									<view class="uni-h5" style="flex: 1;">门：</view>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_openDoor')">开门</button>
								</view>
								<view class="flex-center">
									<view class="uni-h5" style="flex: 1;">电锁：</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_unlock')">打开</button>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_lock')">关闭</button>
								</view>
								<view class="flex-center uni-pt-1">
									<view class="uni-h5" style="flex: 1;">灯光：</view>
									<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('Recycle_lightOn')">打开</button>
									<button class="uni-mt-1" size="mini" @click="check('Recycle_lightOff')">关闭</button>
								</view>
							</view>
						</uni-card>
						<uni-card margin="5px" spacing="0px" padding="5px">
							<view class="flex-center">
								<view class="uni-h5">校准质量：</view>
								<uni-easyinput  v-model="recycle.weightSet" placeholder="" :clearable="false" :inputBorder="true" type="number" />
								<view class="uni-h5 uni-ml-3">10g</view>
							</view>
							<view class="flex-center uni-pt-1">
								<view class="uni-h5" style="flex: 1;">控制：</view>
								<button class="uni-mt-1 uni-mr-2" size="mini" @click="check('recycleFunc.clear')">清零</button>
								<button class="uni-mt-1" size="mini" @click="check('recycleFunc.check')">校准</button>
							</view>
						</uni-card>
					</scroll-view>
				</swiper-item> -->
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">
						<uni-card margin="5px" spacing="0" padding="5px">
							<uni-row>
								<uni-col :span="12">
									<view class="flex-center uni-mr-4">
										<view class="uni-h5">满桶时间(s):</view>
										<uni-easyinput v-model="recycle.warnTime" placeholder="" :clearable="false" :inputBorder="true" type="number" />										
									</view>
									<view class="flex-center uni-mt-1 uni-mr-4">
										<view class="uni-h5">推出时间(s):</view>
										<uni-easyinput v-model="recycle.pushTime" placeholder="" :clearable="false" :inputBorder="true" type="number" />								
									</view>
									<view class="flex-center uni-mt-1 uni-mr-4">
										<view class="uni-h5">保持时间(s):</view>
										<uni-easyinput v-model="recycle.holdTime" placeholder="" :clearable="false" :inputBorder="true" type="number" />									
									</view>
									<view class="flex-center uni-mt-1 uni-mr-4">
										<view class="uni-h5">缩回时间(s):</view>
										<uni-easyinput  v-model="recycle.backTime" placeholder="" :clearable="false" :inputBorder="true" type="number" />										
									</view>
									
									<view class="flex-center uni-mt-1 uni-mr-4">
										<view class="uni-h5">计数滤波:</view>
										<uni-easyinput v-model="recycle.countFilter" placeholder="" :clearable="false" :inputBorder="true" type="number" />										
									</view>
									<view class="flex-center uni-mt-1 uni-mr-4">
										<view class="uni-h5">语音音量:</view>
										<uni-easyinput v-model="recycle.volume" placeholder="" :clearable="false" :inputBorder="true" type="number" />										
									</view>
									<view class="flex-center uni-mt-1 uni-mr-4">
										<view class="uni-h5">增益:</view>
										<uni-easyinput v-model="recycle.gain" placeholder="" :clearable="false" :inputBorder="true" type="text" />
									</view>
									<view class="flex-center uni-mt-1 uni-mr-4">
										<view class="uni-h5" style="flex: 1;">id：</view>
										<view class="width-1" style="position: relative;z-index: 10;">
											<uni-data-select
											      v-model="recycle.modbusId"
											      :localdata="serial.slave_list"												      
												  :clear="false"
											></uni-data-select>
										</view>
									</view>
								</uni-col>
								<uni-col :span="12">
									<view class="flex-center">
										<view class="uni-h5">开电流(mA):</view>
										<uni-easyinput  v-model="recycle.current_open" placeholder="" :clearable="false" :inputBorder="true" type="number"/>										
									</view>
									<view class="flex-center">
										<view class="uni-h5">关电流(mA):</view>
										<uni-easyinput  v-model="recycle.current_close" placeholder="" :clearable="false" :inputBorder="true" type="number"/>										
									</view>									
									<view class="flex-center uni-mt-1">
										<view class="uni-h5">行程:</view>
										<uni-easyinput v-model="recycle.distanceRange  " placeholder="" :clearable="false" :inputBorder="true" type="number" />								
									</view>
									<view class="flex-center uni-mt-1">
										<view class="uni-h5">开关门下限:</view>
										<uni-easyinput v-model="recycle.distanceLimit" placeholder="" :clearable="false" :inputBorder="true" type="number" />										
									</view>
									<view class="flex-center uni-mt-1">
										<view class="uni-h5">减速区间:</view>
										<uni-easyinput v-model="recycle.distanceSlow" placeholder="" :clearable="false" :inputBorder="true" type="number" />										
									</view>
									<view class="flex-center uni-mt-1">
										<view class="uni-h5">关紧电流(mA):</view>
										<uni-easyinput v-model="recycle.smallCurrent" placeholder="" :clearable="false" :inputBorder="true" type="number" />										
									</view>
									<view class="flex-center uni-mt-1">
										<view class="uni-h5">正常电流(mA):</view>
										<uni-easyinput v-model="recycle.current_normal" placeholder="" :clearable="false" :inputBorder="true" type="number" />										
									</view>
									<view class="flex-center uni-mt-1">
										<view class="uni-h5">零偏:</view>
										<uni-easyinput v-model="recycle.offset" placeholder="" :clearable="false" :inputBorder="true" type="text" />
									</view>
									<view class="flex-center">
										<view class="uni-h5" style="flex: 1">控制板类型:</view>
										<view class="width-1" style="position: relative;z-index: 9;">
											<uni-data-select
											      v-model="recycle.board"
											      :localdata="recycle.boardList"												      
												  :clear="false"
											></uni-data-select>
										</view>
									</view>
								</uni-col>
							</uni-row>								
							<uni-data-checkbox width="300rpx" v-model="recycle.configNL" :multiple="true" :localdata="recycle.configList_GS24NL" mode="default" @change="recycleFunc.change_FuncNL" />
							<view class="divider"></view>
							<uni-data-checkbox width="300rpx" v-model="recycle.configNH" :multiple="true" :localdata="recycle.configList_GS24NH" mode="default" @change="recycleFunc.change_FuncNH" />
							<view class="flex-center uni-mt-1">
								<button size="mini" @click="check('recycleFunc.configRead')">读取</button>
								<button size="mini" @click="check('recycleFunc.configWrite')">写入</button>							
								<button size="mini" @click="check('recycleFunc.save')">保存</button>
								<button size="mini" @click="check('recycleFunc.reset')">重启</button>
							</view>
						</uni-card>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 扭矩转速 -->		
		<view v-else-if="global.board == '扭矩转速'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_A" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>	
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<uni-row>
								<uni-col :span="12">
									<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
									<scroll-view class="device_list" scroll-y scroll-with-animation>
									  <view
									    v-for="(item, index) in blue.devices"
									    :key="index"
									    :data-device-id="item.deviceId"
									    :data-name="item.name || item.localName"
									    @click="bleService.createBLEConnection($event)"
									    class="device_item"
									    hover-class="device_item_hover"
										>
									    <view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
									    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
										</view>
									  </view>
									</scroll-view>								
								</uni-col>
								<uni-col :span="12">
									<view class="text-center">
										<text class="uni-h5">蓝牙配置</text>
										<view class="flex-center">
											<view class="width-1 uni-h5">波特率</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.baudRate_BLE"
													  :localdata="serial.baudRateList_BLE"
													  @change="change.baudRate_BLE"
													  :clear="false"
												></uni-data-select>
											</view>														
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">停止位</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.stopBit_BLE"
													  :localdata="serial.stopBitList_BLE"
													  @change="change.stopBit_BLE"
													  :clear="false"
												></uni-data-select>
											</view>													
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">校验</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.checkout_BLE"
													  :localdata="serial.checkoutList_BLE"
													  @change="change.checkout_BLE"
													  :clear="false"
												></uni-data-select>
											</view>										
										</view>
										<view class="flex-center uni-pt-2">
											<button type="default" size="mini" @click="searchBaudRate">扫描</button>
											<button type="default" size="mini" @click="stopSearchBaudRate">停止</button>
										</view>
										<view class="uni-mt-10 uni-h5">重启设备</view>									
										<view class="uni-mt-3">
											<button type="default" size="mini" @click="check('Reset')">重启</button>
										</view>
										
									</view>
								</uni-col>
							</uni-row>
							<view class="flex-center uni-pt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>														
							</view>
						</uni-card>
					</view>
				</swiper-item>
				<swiper-item>
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">
							<view v-if="T_S.runMode" class="">
								<uni-row>
									<uni-col :span="18">
										<view class="flex-center uni-h2">
											<view class="uni-pr-2">转矩DAC</view>									
											<uni-easyinput v-model="T_S.torqueDAC" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											<view class="uni-pl-2 uni-h2">mV</view>											
										</view>
										<view class="flex-center uni-h2">
											<view class="uni-pr-2">转速DAC</view>
											<uni-easyinput v-model="T_S.speedDAC" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											<view class="uni-pl-2">mV</view>											
										</view>
									</uni-col>
									<uni-col :span="6">
										<view class="flex-center uni-pt-4">
											<button class="uni-pl-6 uni-pr-6" type="default" size="mini" @click="check('TSAFunc.write_DAC')">写入</button>
											<button class="uni-pl-6 uni-pr-6" size="mini" @click="check('TSAFunc.open_DAC')">打开</button>
										</view>										
										<view class="flex-center uni-pt-4">
											<button class="uni-pl-6 uni-pr-6" type="default" size="mini" @click="check('TSAFunc.read_DAC')">读取</button>
											<button class="uni-pl-6 uni-pr-6" size="mini" @click="check('TSAFunc.close_DAC')">关闭</button>
										</view>										
									</uni-col>
								</uni-row>								
							</view>
							<view v-else class="">
								<uni-row>
									<uni-col :span="18">
										<view class="flex-center uni-h2">
											<view class="">转矩</view>									
											<view class="width-4 background-color uni-radius text-center uni-ma-2">{{T_S.torque}}</view>
											<view class="">N.m</view>							
										</view>
										<view class="flex-center uni-h2">
											<view class="">转速</view>
											<view class="width-4 background-color uni-radius text-center uni-ma-2">{{T_S.speed}}</view>
											<view class="">rpm</view>							
										</view>									
									</uni-col>
									<uni-col :span="6">
										<view class="flex-column text-center uni-mt-8">
											<view>
												<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
												<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
											</view>
											<view>
												<button type="default" size="mini" @click="check('TSAFunc.stateRead')">读取</button>
											</view>																															
										</view>
									</uni-col>
								</uni-row>
							</view>						
						</uni-card>				
					</view>
				</swiper-item>
				<swiper-item>
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-row>
								<uni-col :span="12">
									<uni-table border stripe>
										<uni-tr>
											<uni-th width="48" align="center">转矩</uni-th>
											<uni-th width="66" align="center">设定值</uni-th>
											<uni-th width="66" align="center">实际值</uni-th>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样1</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.torqueSet1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.torqueReal1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样2</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.torqueSet2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.torqueReal2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>										
									</uni-table>
									<view class="flex-center uni-mt-2">
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.sample_T1')">采样1</button>
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.sample_T2')">采样2</button>
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.check_T')">校准</button>
									</view>
								</uni-col>
								<uni-col :span="12">
									<uni-table border stripe>
										<uni-tr>
											<uni-th width="48" align="center">速度</uni-th>
											<uni-th width="66" align="center">设定值</uni-th>
											<uni-th width="66" align="center">实际值</uni-th>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样1</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.speedSet1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.speedReal1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样2</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.speedSet2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.speedReal2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>										
									</uni-table>
									<view class="flex-center uni-mt-2">
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.sample_S1')">采样1</button>
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.sample_S2')">采样2</button>
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.check_S')">校准</button>
									</view>
								</uni-col>
							</uni-row>
							<view class="flex-center uni-mt-2">
								<button size="mini" @click="check('TSAFunc.check_F')">频率校准</button>
								<button size="mini" @click="check('TSAFunc.check_close')">取消校准</button>
							</view>						
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-table stripe>
								<uni-tr>
									<uni-th width="70" align="center"></uni-th>
									<uni-th width="100" align="center"></uni-th>
									<uni-th width="70" align="center"></uni-th>
									<uni-th width="100" align="center"></uni-th>
								</uni-tr>
								<uni-tr>
									<uni-td align="center">
										<view class="">扭矩增益</view>
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="T_S.torqueGain" placeholder="" :clearable="false" :inputBorder="true" type="text" />	
									</uni-td>
									<uni-td align="center">
										<view class="">扭矩零偏</view>
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="T_S.torqueOffset" placeholder="" :clearable="false" :inputBorder="true" type="text" />	
									</uni-td>
								</uni-tr>							
								<uni-tr>								
									<uni-td align="center">
										<view class="">速度增益</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="T_S.speedGain" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
									<uni-td align="center">
										<view class="">速度零偏</view>
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="T_S.speedOffset" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
								</uni-tr>							
								<uni-tr>									
									<uni-td align="center">
										<view class="">频率偏置</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="T_S.frequencyOffset" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>									
								</uni-tr>								
							</uni-table>
							<view class="flex-center uni-pt-2">
								<button size="mini" @click="check('TSAFunc.checkRead')">读取</button>
								<button size="mini" @click="check('TSAFunc.checkWrite')">写入</button>							
								<button size="mini" @click="check('save')">保存</button>
							</view>
						</uni-card>					
					</view>
				</swiper-item>
				<swiper-item>
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">
							<view class="text-center">
								<uni-group  title="串口配置">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center">
												<view class="width-1">ModbusID</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.modbusId"
														  :localdata="serial.slave_list"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-2">
												<view class="width-1">校验</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.checkout"
														  :localdata="serial.checkoutList"														  
														  :clear="false"
													></uni-data-select>
												</view>												
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center">
												<view class="width-1">波特率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.baudRate"
														  :localdata="serial.baudRateList"														  
														  :clear="false"
													></uni-data-select>
												</view>														
											</view>
											<view class="flex-center uni-pt-2">
												<view class="width-1">停止位</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.stopBit"
														  :localdata="serial.stopBitList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>串口配置</view>
										<button size="mini" @click="check('serialRead')">读取</button>
										<button size="mini" @click="check('serialWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="传感器配置">
									<uni-row>
										<uni-col :span="12">													
											<view class="flex-center uni-pt-2">
												<view class="width-3">扭矩量程(N.m)</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.torqueRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>	
											<view class="flex-center uni-pt-2">
												<view class="width-3">速度量程(rpm)</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											
										</uni-col>
										<uni-col :span="12">											
											<view class="flex-center uni-pt-2">
												<view class="width-1">运行模式</view>
												<view class="width-2">
													<uni-data-select
														  v-model="T_S.runMode"
														  :localdata="T_S.modeList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-2">
												<view class="width-3">一圈脉冲数</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.pulseSet" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>传感器配置</view>
										<button size="mini" @click="check('TSAFunc.sensorRead')">读取</button>
										<button size="mini" @click="check('TSAFunc.sensorWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
							</view>									
							<view class="flex-center uni-pt-2">
								<button size="mini" @click="check('TSAFunc.configRead')">全读</button>
								<button size="mini" @click="check('TSAFunc.configWrite')">全写</button>							
								<button size="mini" @click="check('save')">保存</button>
							</view>
						</uni-card>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<!-- ZN-TSA-01 -->
		<view v-else-if="global.board == 'ZN-TSA-01'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_A" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>	
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<uni-row>
								<uni-col :span="12">
									<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
									<scroll-view class="device_list" scroll-y scroll-with-animation>
									  <view
									    v-for="(item, index) in blue.devices"
									    :key="index"
									    :data-device-id="item.deviceId"
									    :data-name="item.name || item.localName"
									    @click="bleService.createBLEConnection($event)"
									    class="device_item"
									    hover-class="device_item_hover"
										>
									    <view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
									    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
										</view>
									  </view>
									</scroll-view>								
								</uni-col>
								<uni-col :span="12">
									<view class="text-center">
										<text class="uni-h5">蓝牙配置</text>
										<view class="flex-center">
											<view class="width-1 uni-h5">波特率</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.baudRate_BLE"
													  :localdata="serial.baudRateList_BLE"
													  @change="change.baudRate_BLE"
													  :clear="false"
												></uni-data-select>
											</view>														
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">停止位</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.stopBit_BLE"
													  :localdata="serial.stopBitList_BLE"
													  @change="change.stopBit_BLE"
													  :clear="false"
												></uni-data-select>
											</view>													
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">校验</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.checkout_BLE"
													  :localdata="serial.checkoutList_BLE"
													  @change="change.checkout_BLE"
													  :clear="false"
												></uni-data-select>
											</view>										
										</view>
										<view class="flex-center uni-pt-2">
											<button type="default" size="mini" @click="searchBaudRate">扫描</button>
											<button type="default" size="mini" @click="stopSearchBaudRate">停止</button>
										</view>
										<view class="uni-mt-10 uni-h5">重启设备</view>									
										<view class="uni-mt-3">
											<button type="default" size="mini" @click="check('Reset')">重启</button>
										</view>
										
									</view>
								</uni-col>
							</uni-row>
							<view class="flex-center uni-pt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>														
							</view>
						</uni-card>
					</view>
				</swiper-item>
				<swiper-item>
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-row>
								<uni-col :span="18">
									<view class="flex-center uni-h2">
										<view class="">转矩</view>									
										<view class="width-4 background-color uni-radius text-center uni-ma-2">{{T_S.torque}}</view>
										<view class="">N.m</view>							
									</view>
									<view class="flex-center uni-h2">
										<view class="">转速</view>
										<view class="width-4 background-color uni-radius text-center uni-ma-2">{{T_S.speed}}</view>
										<view class="">rpm</view>							
									</view>									
								</uni-col>
								<uni-col :span="6">
									<view class="flex-column text-center uni-mt-8">
										<view>
											<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
											<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
										</view>
										<view>
											<button type="default" size="mini" @click="check('TSAFunc.stateRead')">读取</button>
										</view>																															
									</view>
								</uni-col>
							</uni-row>
							<uni-card margin="2px" spacing="0" padding="0">
								<uni-table border stripe>
									<uni-tr>																				
										<uni-th width="55" align="center">角度(°)</uni-th>
										<uni-th width="55" align="center">总脉冲数</uni-th>											
									</uni-tr>
									<uni-tr>												
										<uni-td align="center">
											<view class="">{{T_S.angle}}</view>													
										</uni-td>
										<uni-td align="center">
											<view class="">{{T_S.pulse}}</view>													
										</uni-td>											
									</uni-tr>																			
								</uni-table>
								<uni-data-checkbox width="220rpx"  v-model="T_S.warn" :multiple="true" :localdata="T_S.warnList" mode="default" />
							</uni-card>	
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-row>
								<uni-col :span="17">
									<view class="flex-center uni-h2">
										<view class="uni-mr-2">转矩DAC</view>									
										<uni-easyinput v-model="T_S.torqueDAC" placeholder="" :clearable="false" :inputBorder="true" type="text" />
										<view class="uni-ml-2">mV</view>											
									</view>
									<view class="flex-center uni-h2">
										<view class="uni-mr-2">转速DAC</view>
										<uni-easyinput v-model="T_S.speedDAC" placeholder="" :clearable="false" :inputBorder="true" type="text" />
										<view class="uni-ml-2">mV</view>											
									</view>
								</uni-col>
								<uni-col :span="7">
									<view class="flex-center uni-mt-4">
										<button class="uni-px-5" type="default" size="mini" @click="check('TSAFunc.write_DAC')">写入</button>
										<button class="uni-px-5" size="mini" @click="check('TSAFunc.open_DAC')">打开</button>
									</view>										
									<view class="flex-center uni-mt-4">
										<button class="uni-px-5" type="default" size="mini" @click="check('TSAFunc.read_DAC')">读取</button>
										<button class="uni-px-5" size="mini" @click="check('TSAFunc.close_DAC')">关闭</button>
									</view>										
								</uni-col>
							</uni-row>					
						</uni-card>
					</view>
				</swiper-item>
				<swiper-item>
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-row>
								<uni-col :span="12">
									<uni-table border stripe>
										<uni-tr>
											<uni-th width="48" align="center">转矩</uni-th>
											<uni-th width="66" align="center">设定值</uni-th>
											<uni-th width="66" align="center">实际值</uni-th>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样1</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.torqueSet1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.torqueReal1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样2</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.torqueSet2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.torqueReal2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>										
									</uni-table>
									<view class="flex-center uni-mt-2">
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.sample_T1')">采样1</button>
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.sample_T2')">采样2</button>
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.check_T')">校准</button>
									</view>
								</uni-col>
								<uni-col :span="12">
									<uni-table border stripe>
										<uni-tr>
											<uni-th width="48" align="center">速度</uni-th>
											<uni-th width="66" align="center">设定值</uni-th>
											<uni-th width="66" align="center">实际值</uni-th>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样1</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.speedSet1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.speedReal1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样2</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.speedSet2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="T_S.speedReal2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>										
									</uni-table>
									<view class="flex-center uni-mt-2">
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.sample_S1')">采样1</button>
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.sample_S2')">采样2</button>
										<button class="uni-px-4" size="mini" @click="check('TSAFunc.check_S')">校准</button>
									</view>
								</uni-col>
							</uni-row>
							<view class="flex-center uni-pt-2">
								<button size="mini" @click="check('TSAFunc.check_F')">转矩清零</button>
								<button size="mini" @click="check('TSAFunc.check_close')">取消校准</button>
							</view>						
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-table stripe>
								<uni-tr>
									<uni-th width="70" align="center"></uni-th>
									<uni-th width="100" align="center"></uni-th>
									<uni-th width="70" align="center"></uni-th>
									<uni-th width="100" align="center"></uni-th>
								</uni-tr>
								<uni-tr>
									<uni-td align="center">
										<view class="">扭矩增益</view>
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="T_S.torqueGain" placeholder="" :clearable="false" :inputBorder="true" type="text" />	
									</uni-td>
									<uni-td align="center">
										<view class="">扭矩零偏</view>
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="T_S.torqueOffset" placeholder="" :clearable="false" :inputBorder="true" type="text" />	
									</uni-td>
								</uni-tr>							
								<uni-tr>								
									<uni-td align="center">
										<view class="">速度增益</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="T_S.speedGain" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
									<uni-td align="center">
										<view class="">速度零偏</view>
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="T_S.speedOffset" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
								</uni-tr>							
								<uni-tr>									
									<uni-td align="center">
										<view class="">转矩偏置</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="T_S.frequencyOffset" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>									
								</uni-tr>								
							</uni-table>
							<view class="flex-center uni-pt-2">
								<button size="mini" @click="check('TSAFunc.checkRead')">读取</button>
								<button size="mini" @click="check('TSAFunc.checkWrite')">写入</button>							
								<button size="mini" @click="check('save')">保存</button>
							</view>
						</uni-card>					
					</view>
				</swiper-item>
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">
						<uni-card margin="3px" spacing="0" padding="3px">
							<view class="text-center">
								<uni-group title="串口1配置">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">ModbusID</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.modbusId"
														  :localdata="serial.slave_list"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校验</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.checkout"
														  :localdata="serial.checkoutList"														  
														  :clear="false"
													></uni-data-select>
												</view>
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">回复延时(ms)</view>
												<view class="width-2">												
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">波特率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.baudRate"
														  :localdata="serial.baudRateList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">停止位</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.stopBit"
														  :localdata="serial.stopBitList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view class="">串口1配置</view>
										<button size="mini" @click="check('serialRead')">读取</button>
										<button size="mini" @click="check('serialWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="串口2配置">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center">
												<view class="width-1">ModbusID</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.modbusId_2"
														  :localdata="serial.slave_list"														  
														  :clear="false"
														  :disabled="true"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校验</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.checkout_2"
														  :localdata="serial.checkoutList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">回复延时(ms)</view>
												<view class="width-2">												
													<uni-easyinput @change="change.reply2" v-model="serial.reply_2" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>										
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center">
												<view class="width-1">波特率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.baudRate_2"
														  :localdata="serial.baudRateList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">停止位</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.stopBit_2"
														  :localdata="serial.stopBitList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">串口2功能</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.port2"
														  :localdata="serial.port2List"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>									
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view class="">串口2配置</view>
										<button size="mini" @click="check('serialRead2')">读取</button>
										<button size="mini" @click="check('serialWrite2')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="传感器配置">
									<uni-row>
										<uni-col :span="12">													
											<view class="flex-center">
												<view class="width-3">扭矩量程(N.m)</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.torqueRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>	
											<view class="flex-center uni-pt-1">
												<view class="width-3">速度量程(rpm)</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>	
											<view class="flex-center uni-pt-1">
												<view class="width-3">角度量程(°)</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.angleRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">扭矩小数位</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.decimal_T" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">转速小数位</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.decimal_S" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">角度小数位</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.decimal_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">编码器线数</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.pulseSet" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>											
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center">
												<view class="width-1">模式配置</view>
												<view class="width-2">
													<uni-data-select
														  v-model="T_S.type"
														  :localdata="T_S.typeList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">工作模式</view>
												<view class="width-2">
													<uni-data-select
														  v-model="T_S.runMode"
														  :localdata="T_S.modeList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">扭矩极性</view>
												<view class="width-2">
													<uni-data-select
														  v-model="T_S.polarity_T"
														  :localdata="T_S.polarityList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">转速极性</view>
												<view class="width-2">
													<uni-data-select
														  v-model="T_S.polarity_S"
														  :localdata="T_S.polarityList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>											
											<view class="flex-center uni-pt-1">
												<view class="width-3">转矩截止频率</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.frequencyCutoff_T" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">转速滤波频率</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.frequencyFilter_S" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>传感器配置</view>
										<button size="mini" @click="check('TSAFunc.sensorRead')">读取</button>
										<button size="mini" @click="check('TSAFunc.sensorWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
							</view>									
							<view class="flex-center">
								<button size="mini" @click="check('TSAFunc.configRead')">全读</button>
								<button size="mini" @click="check('TSAFunc.configWrite')">全写</button>							
								<button size="mini" @click="check('save')">保存</button>
							</view>						
						</uni-card>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		<!-- ZN-WTA-02 -->
		<view v-else-if="global.board == 'ZN-WTA-02'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_A" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>	
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<uni-row>
								<uni-col :span="12">
									<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
									<scroll-view class="device_list" scroll-y scroll-with-animation>
									  <view
									    v-for="(item, index) in blue.devices"
									    :key="index"
									    :data-device-id="item.deviceId"
									    :data-name="item.name || item.localName"
									    @click="bleService.createBLEConnection($event)"
									    class="device_item"
									    hover-class="device_item_hover"
										>
									    <view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
									    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
										</view>
									  </view>
									</scroll-view>								
								</uni-col>
								<uni-col :span="12">
									<view class="text-center">
										<text class="uni-h5">蓝牙配置</text>
										<view class="flex-center">
											<view class="width-1 uni-h5">波特率</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.baudRate_BLE"
													  :localdata="serial.baudRateList_BLE"
													  @change="change.baudRate_BLE"
													  :clear="false"
												></uni-data-select>
											</view>														
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">停止位</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.stopBit_BLE"
													  :localdata="serial.stopBitList_BLE"
													  @change="change.stopBit_BLE"
													  :clear="false"
												></uni-data-select>
											</view>													
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">校验</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.checkout_BLE"
													  :localdata="serial.checkoutList_BLE"
													  @change="change.checkout_BLE"
													  :clear="false"
												></uni-data-select>
											</view>										
										</view>
										<view class="flex-center uni-pt-2">
											<button type="default" size="mini" @click="searchBaudRate">扫描</button>
											<button type="default" size="mini" @click="stopSearchBaudRate">停止</button>
										</view>
										<view class="uni-mt-10 uni-h5">重启设备</view>									
										<view class="uni-mt-3">
											<button type="default" size="mini" @click="check('Reset')">重启</button>
										</view>
										
									</view>
								</uni-col>
							</uni-row>
							<view class="flex-center uni-pt-2">
								<view class="">
									<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								</view>
								<view class="">
									<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>
								</view>							
								<view v-if="blue.connected" class="">
									<button type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>
								</view>							
							</view>
						</uni-card>
					</view>
				</swiper-item>
				<swiper-item>					
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">						
							<view class="">
								<uni-row>
									<uni-col :span="18">
										<view class="flex-center uni-h2">
											<view class="">重量1</view>									
											<view class="width-4 background-color uni-radius text-center uni-ma-2">{{WTA.weight1}}</view>
											<view class="">{{WTA.weightUnitList[WTA.weightUnit].text}}</view>							
										</view>
										<view class="flex-center uni-h2">
											<view class="">重量2</view>
											<view class="width-4 background-color uni-radius text-center uni-ma-2">{{WTA.weight2}}</view>
											<view class="">{{WTA.weightUnitList[WTA.weightUnit].text}}</view>
										</view>									
									</uni-col>
									<uni-col :span="6">
										<view class="flex-column text-center uni-mt-8">
											<view class="">
												<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
												<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
											</view>
											<view class="">
												<button type="default" size="mini" @click="check('WTA_read')">读取</button>
											</view>								
										</view>
									</uni-col>
								</uni-row>
								<uni-row>
									<uni-col :span="12">
										<uni-card title="传感器1" margin="1px" spacing="0" padding="0">
											<uni-table border stripe>
												<uni-tr>																				
													<uni-th width="55" align="center">温度(℃)</uni-th>
													<uni-th width="55" align="center">电流(mA)</uni-th>											
												</uni-tr>
												<uni-tr>												
													<uni-td align="center">
														<view class="">{{WTA.temperature1}}</view>													
													</uni-td>
													<uni-td align="center">
														<view class="">{{WTA.current1}}</view>													
													</uni-td>											
												</uni-tr>																			
											</uni-table>
											<uni-data-checkbox  v-model="WTA.warn1" :multiple="true" :localdata="WTA.warnList" mode="default" />
										</uni-card>
									</uni-col>
									<uni-col :span="12">
										<uni-card title="传感器2" margin="1px" spacing="0" padding="0">
											<uni-table border stripe>
												<uni-tr>																				
													<uni-th width="55" align="center">温度(℃)</uni-th>
													<uni-th width="55" align="center">电流(mA)</uni-th>											
												</uni-tr>											
												<uni-tr>												
													<uni-td align="center">
														<view class="">{{WTA.temperature2}}</view>													
													</uni-td>
													<uni-td align="center">
														<view class="">{{WTA.current2}}</view>													
													</uni-td>											
												</uni-tr>								
											</uni-table>
											<uni-data-checkbox  v-model="WTA.warn2" :multiple="true" :localdata="WTA.warnList" mode="default" />
										</uni-card>
									</uni-col>
								</uni-row>
							</view>
						</uni-card>
					</view>					
				</swiper-item>
				<swiper-item>					
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">						
							<view class="">							
								<uni-row>
									<uni-col :span="18">
										<view class="flex-center uni-h2">
											<view class="">重量1</view>									
											<view class="width-4 background-color uni-radius text-center uni-ma-2">{{WTA.weight1}}</view>
											<view class="">{{WTA.weightUnitList[WTA.weightUnit].text}}</view>							
										</view>
										<view class="flex-center uni-h2">
											<view class="">重量2</view>
											<view class="width-4 background-color uni-radius text-center uni-ma-2">{{WTA.weight2}}</view>
											<view class="">{{WTA.weightUnitList[WTA.weightUnit].text}}</view>
										</view>									
									</uni-col>
									<uni-col :span="6">
										<view class="flex-column text-center uni-mt-8">
											<view class="">
												<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
												<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
											</view>
											<view class="">
												<button type="default" size="mini" @click="check('WTA_read')">读取</button>
											</view>								
										</view>
									</uni-col>
								</uni-row>
							</view>
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">						
							<uni-row>
								<uni-col :span="10">
									<uni-table border stripe>
										<uni-tr>
											<uni-th width="60" align="center"></uni-th>
											<uni-th width="60" align="center"></uni-th>										
										</uni-tr>
										<uni-tr>
											<uni-td align="center">重量(g)</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="WTA.weightSet" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>										
										</uni-tr>										
									</uni-table>
									<view class="flex-center uni-mt-2">
										<button size="mini" @click="check('WTA_clear')">清零</button>
										<button size="mini" @click="check('WTA_check')">校准</button>
									</view>
									<view class="uni-mt-3 text-center">
										<button size="mini" @click="check('TSAFunc.check_close')">取消校准</button>
									</view>
										
								</uni-col>
								<uni-col :span="14">
									<uni-table border stripe>
										<uni-tr>
											<uni-th width="48" align="center">DAC</uni-th>
											<uni-th width="66" align="center">设定值</uni-th>
											<uni-th width="66" align="center">实际值</uni-th>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样1</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="WTA.DACset1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="WTA.DACReal1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样2</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="WTA.DACset2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="WTA.DACReal2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>										
									</uni-table>
									<view class="flex-center uni-mt-2">
										<button class="uni-px-4" size="mini" @click="check('WTA_DACSample1')">采样1</button>
										<button class="uni-px-4" size="mini" @click="check('WTA_DACSample2')">采样2</button>
										<button class="uni-px-4" size="mini" @click="check('WTA_DACCheck')">校准</button>
									</view>
								</uni-col>
							</uni-row>											
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-table stripe>
								<uni-tr>
									<uni-th width="70" align="center"></uni-th>
									<uni-th width="100" align="center"></uni-th>
									<uni-th width="70" align="center"></uni-th>
									<uni-th width="100" align="center"></uni-th>
								</uni-tr>
								<uni-tr>									
									<uni-td align="center">
										<view class="">重量增益</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="WTA.weightGain" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
									<uni-td align="center">
										<view class="">重量偏置</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="WTA.weightOffset" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
								</uni-tr>
								<uni-tr>
									<uni-td align="center">
										<view class="">DAC增益</view>
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="WTA.DACGain" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
									<uni-td align="center">
										<view class="">DAC偏置</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="WTA.DACOffset" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
								</uni-tr>										
							</uni-table>
							<view class="flex-center uni-pt-2">
								<button size="mini" @click="check('WTA_checkRead')">读取</button>
								<button size="mini" @click="check('WTA_checkWrite')">写入</button>							
								<button size="mini" @click="check('save')">保存</button>
							</view>
						</uni-card>
					</view>					
				</swiper-item>
				<swiper-item>					
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">
							<view class="text-center">
								<uni-group title="串口配置">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">ModbusID</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.modbusId"
														  :localdata="serial.slave_list"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校验</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.checkout"
														  :localdata="serial.checkoutList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">波特率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.baudRate"
														  :localdata="serial.baudRateList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">停止位</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.stopBit"
														  :localdata="serial.stopBitList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>串口配置</view>
										<button size="mini" @click="check('serialRead')">读取</button>
										<button size="mini" @click="check('serialWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="传感器配置">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">极性</view>
												<view class="width-2">
													<uni-data-select
														  v-model="WTA.polarity"
														  :localdata="WTA.polarityList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">采样频率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="WTA.sampleRate"
														  :localdata="WTA.sampleRateList02"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">倍数</view>
												<view class="width-2">
													<uni-data-select
														  v-model="WTA.mult"
														  :localdata="WTA.multList"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>													
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>传感器配置</view>
										<button size="mini" @click="check('WTA_sensorRead')">读取</button>
										<button size="mini" @click="check('WTA_sensorWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="重量配置">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-3">重量量程</view>
												<view class="width-2">
													<uni-easyinput v-model="WTA.weightRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">正常电流mA</view>
												<view class="width-2">
													<uni-easyinput v-model="WTA.current_normal" placeholder="" :clearable="false" :inputBorder="true" type="text" />														
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">重量单位</view>
												<view class="width-2">
													<uni-data-select
														  v-model="WTA.weightUnit"
														  :localdata="WTA.weightUnitList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>	
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>重量配置</view>
										<button size="mini" @click="check('WTA_weightRead')">读取</button>
										<button size="mini" @click="check('WTA_weightWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
							</view>
							<view class="flex-center uni-mt-2">
								<button size="mini" @click="check('WTA_readConfig')">全读</button>
								<button size="mini" @click="check('WTA_write')">全写</button>							
								<button size="mini" @click="check('save')">保存</button>
							</view>
						</uni-card>
					</view>								
				</swiper-item>
			</swiper>
		</view>
		<!-- ZN-WTA-01 -->
		<view v-else-if="global.board == 'ZN-WTA-01'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_A" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>	
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<uni-row>
								<uni-col :span="12">
									<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
									<scroll-view class="device_list" scroll-y scroll-with-animation>
									  <view
									    v-for="(item, index) in blue.devices"
									    :key="index"
									    :data-device-id="item.deviceId"
									    :data-name="item.name || item.localName"
									    @click="bleService.createBLEConnection($event)"
									    class="device_item"
									    hover-class="device_item_hover"
										>
									    <view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
									    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
										</view>
									  </view>
									</scroll-view>								
								</uni-col>
								<uni-col :span="12">
									<view class="text-center">
										<text class="uni-h5">蓝牙配置</text>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">波特率</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.baudRate_BLE"
													  :localdata="serial.baudRateList_BLE"
													  @change="change.baudRate_BLE"
													  :clear="false"
												></uni-data-select>
											</view>														
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">停止位</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.stopBit_BLE"
													  :localdata="serial.stopBitList_BLE"
													  @change="change.stopBit_BLE"
													  :clear="false"
												></uni-data-select>
											</view>													
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">校验</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.checkout_BLE"
													  :localdata="serial.checkoutList_BLE"
													  @change="change.checkout_BLE"
													  :clear="false"
												></uni-data-select>
											</view>										
										</view>
										<view class="flex-center uni-pt-2">
											<button type="default" size="mini" @click="searchBaudRate">扫描</button>
											<button type="default" size="mini" @click="stopSearchBaudRate">停止</button>
										</view>
										<view class="uni-mt-10 uni-h5">重启设备</view>									
										<view class="uni-mt-3">
											<button type="default" size="mini" @click="check('Reset')">重启</button>
										</view>
										
									</view>
								</uni-col>
							</uni-row>
							<view class="flex-center uni-pt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>														
							</view>
						</uni-card>
					</view>
				</swiper-item>
				<swiper-item>
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">						
							<view class="">
								<uni-row>
									<uni-col :span="18">
										<view class="flex-center uni-h2 uni-mt-6">
											<view class="">重量</view>									
											<view class="width-4 background-color uni-radius text-center uni-ma-2">{{WTA.weight1}}</view>
											<view class="">{{WTA.weightUnitList[WTA.weightUnit].text}}</view>							
										</view>																			
									</uni-col>
									<uni-col :span="6">
										<view class="flex-column text-center uni-mt-2">
											<view class="">
												<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
												<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
											</view>
											<view class="">
												<button type="default" size="mini" @click="check('WTA01_read')">读取</button>
											</view>								
										</view>
									</uni-col>
								</uni-row>
								<uni-card margin="1px" spacing="0" padding="0">
									<uni-table border stripe>
										<uni-tr>																				
											<uni-th width="55" align="center">温度(℃)</uni-th>
											<uni-th width="55" align="center">电流(mA)</uni-th>											
										</uni-tr>
										<uni-tr>												
											<uni-td align="center">
												<view class="">{{WTA.temperature1}}</view>													
											</uni-td>
											<uni-td align="center">
												<view class="">{{WTA.current1}}</view>													
											</uni-td>											
										</uni-tr>																			
									</uni-table>
									<uni-data-checkbox width="220rpx"  v-model="WTA.warn1" :multiple="true" :localdata="WTA.warnList" mode="default" />
								</uni-card>								
							</view>
						</uni-card>						
					</view>
				</swiper-item>
				<swiper-item>
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">						
							<view class="">							
								<uni-row>
									<uni-col :span="18">
										<view class="flex-center uni-h2 uni-mt-6">
											<view class="">重量</view>									
											<view class="width-4 background-color uni-radius text-center uni-ma-2">{{WTA.weight1}}</view>
											<view class="">{{WTA.weightUnitList[WTA.weightUnit].text}}</view>							
										</view>																			
									</uni-col>
									<uni-col :span="6">
										<view class="flex-column text-center uni-mt-2">
											<view class="">
												<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
												<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
											</view>
											<view class="">
												<button type="default" size="mini" @click="check('WTA01_read')">读取</button>
											</view>								
										</view>
									</uni-col>
								</uni-row>
							</view>
						</uni-card>
						<uni-card margin="3px" spacing="3px 0" padding="3px">
							<view class="text-center">
								<uni-row>
									<uni-col :span="12">
										<view class="flex-center uni-pt-1">
											<view class="width-2">重量({{WTA.weightUnitList[WTA.weightUnit].text}})</view>
											<view class="width-2">
												<uni-easyinput v-model="WTA.weightSet" placeholder="" :clearable="false" :inputBorder="true" type="text" />														
											</view>													
										</view>
									</uni-col>
									<uni-col :span="12">
										<view class="flex-center">
											<button size="mini" @click="check('WTA01_clear')">清零</button>
											<button size="mini" @click="check('WTA01_check')">校准</button>
										</view>									
									</uni-col>
								</uni-row>
							</view>
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-table stripe>
								<uni-tr>
									<uni-th width="80" align="center"></uni-th>
									<uni-th width="80" align="center"></uni-th>
									<uni-th width="80" align="center"></uni-th>
									<uni-th width="80" align="center"></uni-th>
								</uni-tr>
								<uni-tr>									
									<uni-td align="center">
										<view class="">重量增益</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="WTA.weightGain" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
									<uni-td align="center">
										<view class="">重量偏置</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="WTA.weightOffset" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
								</uni-tr>
							</uni-table>
							<view class="flex-center uni-pt-2">
								<button size="mini" @click="check('WTA01_checkRead')">读取</button>
								<button size="mini" @click="check('WTA01_checkWrite')">写入</button>							
								<button size="mini" @click="check('WTA01_save')">保存</button>
							</view>
						</uni-card>					
					</view>
				</swiper-item>
				<swiper-item>
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">
							<view class="text-center">
								<uni-group title="串口配置">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">ModbusID</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.modbusId"
														  :localdata="serial.slave_list"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>											
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">波特率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.baudRate"
														  :localdata="serial.baudRateList"														
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>串口配置</view>
										<button size="mini" @click="check('WTA01_serialRead')">读取</button>
										<button size="mini" @click="check('WTA01_serialWrite')">写入</button>							
										<button size="mini" @click="check('WTA01_save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="传感器配置">
									<uni-row>
										<uni-col :span="12">											
											<view class="flex-center uni-pt-1">
												<view class="width-1">采样频率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="WTA.sampleRate"
														  :localdata="WTA.sampleRateList01"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">																								
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>传感器配置</view>
										<button size="mini" @click="check('WTA01_sensorRead')">读取</button>
										<button size="mini" @click="check('WTA01_sensorWrite')">写入</button>							
										<button size="mini" @click="check('WTA01_save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="重量配置">
									<uni-row>
										<uni-col :span="12">											
											<view class="flex-center uni-pt-1">
												<view class="width-3">正常电流mA</view>
												<view class="width-2">
													<uni-easyinput v-model="WTA.current_normal" placeholder="" :clearable="false" :inputBorder="true" type="text" />														
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">重量单位</view>
												<view class="width-2">
													<uni-data-select
														  v-model="WTA.weightUnit"
														  :localdata="WTA.weightUnitList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>	
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>重量配置</view>
										<button size="mini" @click="check('WTA01_weightRead')">读取</button>
										<button size="mini" @click="check('WTA01_weightWrite')">写入</button>							
										<button size="mini" @click="check('WTA01_save')">保存</button>
									</view>
								</uni-group>
							</view>
							<view class="flex-center uni-mt-2">
								<button size="mini" @click="check('WTA01_readConfig')">全读</button>
								<button size="mini" @click="check('WTA01_write')">全写</button>							
								<button size="mini" @click="check('WTA01_save')">保存</button>
							</view>
						</uni-card>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<!-- ZN-RTD-01 -->
		<view v-else-if="global.board == 'ZN-RTD-01'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_A" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>	
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<uni-row>
								<uni-col :span="12">
									<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
									<scroll-view class="device_list" scroll-y scroll-with-animation>
									  <view
									    v-for="(item, index) in blue.devices"
									    :key="index"
									    :data-device-id="item.deviceId"
									    :data-name="item.name || item.localName"
									    @click="bleService.createBLEConnection($event)"
									    class="device_item"
									    hover-class="device_item_hover"
										>
									    <view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
									    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
										</view>
									  </view>
									</scroll-view>								
								</uni-col>
								<uni-col :span="12">
									<view class="text-center">
										<text class="uni-h5">蓝牙配置</text>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">波特率</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.baudRate_BLE"
													  :localdata="serial.baudRateList_BLE"
													  @change="change.baudRate_BLE"
													  :clear="false"
												></uni-data-select>
											</view>														
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">停止位</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.stopBit_BLE"
													  :localdata="serial.stopBitList_BLE"
													  @change="change.stopBit_BLE"
													  :clear="false"
												></uni-data-select>
											</view>													
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">校验</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.checkout_BLE"
													  :localdata="serial.checkoutList_BLE"
													  @change="change.checkout_BLE"
													  :clear="false"
												></uni-data-select>
											</view>										
										</view>
										<view class="flex-center uni-pt-2">
											<button type="default" size="mini" @click="searchBaudRate">扫描</button>
											<button type="default" size="mini" @click="stopSearchBaudRate">停止</button>
										</view>
										<view class="uni-mt-10 uni-h5">重启设备</view>									
										<view class="uni-mt-3">
											<button type="default" size="mini" @click="check('Reset')">重启</button>
										</view>
										
									</view>
								</uni-col>
							</uni-row>
							<view class="flex-center uni-pt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>															
							</view>
						</uni-card>
					</view>
				</swiper-item>
				<swiper-item>
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">						
							<view class="">
								<uni-row>
									<uni-col :span="18">
										<view class="flex-center uni-h2 uni-mt-8">
											<view class="">温度</view>									
											<view class="width-4 background-color uni-radius text-center uni-ma-2">{{RTD.temperature}}</view>
											<view class="">℃</view>							
										</view>																			
									</uni-col>
									<uni-col :span="6">
										<view class="flex-column text-center uni-mt-2">
											<view class="">
												<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
												<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
											</view>
											<view class="">
												<button type="default" size="mini" @click="check('RTD_read')">读取</button>												
											</view>								
										</view>
									</uni-col>
								</uni-row>
								<uni-card margin="1px" spacing="0" padding="0">
									<uni-table border stripe>
										<uni-tr>																				
											<uni-th width="55" align="center">芯片温度(℃)</uni-th>
											<uni-th width="55" align="center">阻值(Ω)</uni-th>											
										</uni-tr>
										<uni-tr>												
											<uni-td align="center">
												<view class="">{{RTD.chipTemperature}}</view>													
											</uni-td>
											<uni-td align="center">
												<view class="">{{RTD.resistance}}</view>													
											</uni-td>											
										</uni-tr>																			
									</uni-table>
									<uni-data-checkbox width="220rpx" v-model="RTD.warn" :multiple="true" :localdata="RTD.warnList" mode="default" />
								</uni-card>								
							</view>
						</uni-card>						
					</view>
				</swiper-item>
				<swiper-item>
					<view class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">
							<view class="">
								<uni-row>
									<uni-col :span="18">
										<view class="flex-center uni-h2 uni-mt-8">
											<view class="">温度</view>									
											<view class="width-4 background-color uni-radius text-center uni-ma-2">{{RTD.temperature}}</view>
											<view class="">℃</view>							
										</view>																			
									</uni-col>
									<uni-col :span="6">
										<view class="flex-column text-center uni-mt-2">
											<view class="">
												<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
												<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
											</view>
											<view class="">
												<button type="default" size="mini" @click="check('RTD_read')">读取</button>												
											</view>								
										</view>
									</uni-col>
								</uni-row>
							</view>
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">						
							<radio-group class="flex-center uni-my-2" @change="change.analogRange">
								<label v-for="(item,index) in RTD.analogRangeList" :key="item.value">
									<radio :value="item.value" :checked="index === global.current" /><text>{{item.text}}</text>
								</label>									
							</radio-group>
							<uni-row>
								<uni-col :span="10">
									<uni-table border stripe>
										<uni-tr>
											<uni-th width="60" align="center">校准值1</uni-th>
											<uni-th width="60" align="center">校准值2</uni-th>
										</uni-tr>
										<uni-tr>										
											<uni-td align="center">
												<uni-easyinput v-model="RTD.resset1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="RTD.resset2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>										
									</uni-table>
									<view class="flex-center uni-my-2">
										<button size="mini" @click="check('RTD_ResSample1')">阻值1</button>
										<button size="mini" @click="check('RTD_ResSample2')">阻值2</button>										
									</view>
									<view class="uni-mt-2 text-center">
										<button size="mini" @click="check('TSAFunc.check_close')">取消校准</button>
									</view>								
								</uni-col>
								<uni-col :span="14">
									<uni-table border stripe>
										<uni-tr>
											<uni-th width="48" align="center">DAC</uni-th>
											<uni-th width="66" align="center">设定值</uni-th>
											<uni-th width="66" align="center">实际值</uni-th>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样1</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="RTD.DACset1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="RTD.DACReal1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>
										<uni-tr>
											<uni-td align="center">采样2</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="RTD.DACset2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
											<uni-td align="center">
												<uni-easyinput v-model="RTD.DACReal2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
											</uni-td>
										</uni-tr>										
									</uni-table>
									<view class="flex-center uni-mt-2">
										<button class="uni-px-4" size="mini" @click="check('RTD_DACSample1')">采样1</button>
										<button class="uni-px-4" size="mini" @click="check('RTD_DACSample2')">采样2</button>
										<button class="uni-px-4" size="mini" @click="check('RTD_DACCheck')">校准</button>
									</view>
								</uni-col>
							</uni-row>																		
						</uni-card>						
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-table stripe>
								<uni-tr>
									<uni-th width="100" align="center"></uni-th>
									<uni-th width="80" align="center"></uni-th>
									<uni-th width="100" align="center"></uni-th>
									<uni-th width="80" align="center"></uni-th>
								</uni-tr>
								<uni-tr>									
									<uni-td align="center">
										<view class="">ADC增益</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="RTD.ADCGain" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
									<uni-td align="center">
										<view class="">ADC偏置</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="RTD.ADCOffset" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
								</uni-tr>
								<uni-tr>
									<uni-td align="center">
										<view class="">10VDAC增益</view>
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="RTD.DACGain_10V" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
									<uni-td align="center">
										<view class="">10VDAC偏置</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="RTD.DACOffset_10V" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
								</uni-tr>
								<uni-tr>
									<uni-td align="center">
										<view class="">5VDAC增益</view>
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="RTD.DACGain_5V" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
									<uni-td align="center">
										<view class="">5VDAC偏置</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="RTD.DACOffset_5V" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
								</uni-tr>
								<uni-tr>
									<uni-td align="center">
										<view class="">20mADAC增益</view>
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="RTD.DACGain_20mA" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
									<uni-td align="center">
										<view class="">20mADAC偏置</view>												
									</uni-td>
									<uni-td align="center">
										<uni-easyinput v-model="RTD.DACOffset_20mA" placeholder="" :clearable="false" :inputBorder="true" type="text" />												
									</uni-td>
								</uni-tr>
							</uni-table>
							<view class="flex-center uni-pt-2">
								<button size="mini" @click="check('RTD_checkRead')">读取</button>
								<button size="mini" @click="check('RTD_checkWrite')">写入</button>							
								<button size="mini" @click="check('save')">保存</button>
							</view>
						</uni-card>					
					</view>
				</swiper-item>
				<swiper-item>
					<scroll-view scroll-y="true" class="height-1">
						<uni-card margin="3px" spacing="0" padding="3px">
							<view class="text-center">
								<uni-group>
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">ModbusID</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.modbusId"
														  :localdata="serial.slave_list"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校验</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.checkout"
														  :localdata="serial.checkoutList"														 
														  :clear="false"
													></uni-data-select>
												</view>
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">回复延时(ms)</view>
												<view class="width-2">												
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">波特率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.baudRate"
														  :localdata="serial.baudRateList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">停止位</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.stopBit"
														  :localdata="serial.stopBitList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view class="">串口1配置</view>
										<button size="mini" @click="check('serialRead')">读取</button>
										<button size="mini" @click="check('serialWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group>
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">ModbusID</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.modbusId_2"
														  :localdata="serial.slave_list"														 
														  :clear="false"
														  :disabled="true"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校验</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.checkout_2"
														  :localdata="serial.checkoutList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">回复延时(ms)</view>
												<view class="width-2">												
													<uni-easyinput @change="change.reply2" v-model="serial.reply_2" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>										
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">波特率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.baudRate_2"
														  :localdata="serial.baudRateList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">停止位</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.stopBit_2"
														  :localdata="serial.stopBitList"														
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">串口2功能</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.port2"
														  :localdata="serial.port2List"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>									
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view class="">串口2配置</view>
										<button size="mini" @click="check('serialRead2')">读取</button>
										<button size="mini" @click="check('serialWrite2')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group>
									<uni-row>
										<uni-col :span="12">											
											<view class="flex-center uni-pt-1">
												<view class="width-1">传感器类型</view>
												<view class="width-2">
													<uni-data-select
														  v-model="RTD.sensor"
														  :localdata="RTD.sensorList"													 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">采样率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="RTD.sampleRate"
														  :localdata="RTD.sampleRateList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">模拟量输出</view>
												<view class="width-2">
													<uni-data-select
														  v-model="RTD.analogRange"
														  :localdata="RTD.analogRangeList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">温度下限</view>
												<view class="width-2">
													<uni-data-select
														  v-model="RTD.temperature_min"
														  :localdata="RTD.rangeMin"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">温度上限</view>
												<view class="width-2">
													<uni-data-select
														  v-model="RTD.temperature_max"
														  :localdata="RTD.rangeMax"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>											
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view class="">传感器配置</view>
										<button size="mini" @click="check('RTD_sensorRead')">读取</button>
										<button size="mini" @click="check('RTD_sensorWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>								
							</view>
							<view class="flex-center uni-pt-2">
								<button size="mini" @click="check('RTD_readConfig')">全读</button>
								<button size="mini" @click="check('RTD_write')">全写</button>							
								<button size="mini" @click="check('save')">保存</button>
							</view>
						</uni-card>					
					</scroll-view>				
				</swiper-item>
			</swiper>
		</view>
		<!-- 模拟量采集 -->
		<view v-else-if="global.board == '模拟量采集'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_C" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true" >
						<uni-card margin="5px" spacing="0">
							<uni-row>
								<uni-col :span="12">
									<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
									<scroll-view class="device_list" scroll-y scroll-with-animation>
									  <view
									    v-for="(item, index) in blue.devices"
									    :key="index"
									    :data-device-id="item.deviceId"
									    :data-name="item.name || item.localName"
									    @click="bleService.createBLEConnection($event)"
									    class="device_item"
									    hover-class="device_item_hover"
										>
									    <view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
									    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
										</view>
									  </view>
									</scroll-view>								
								</uni-col>
								<uni-col :span="12">
									<view class="text-center">
										<text class="uni-h5">蓝牙配置</text>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">波特率</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.baudRate_BLE"
													  :localdata="serial.baudRateList_BLE"
													  @change="change.baudRate_BLE"
													  :clear="false"
												></uni-data-select>
											</view>														
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">停止位</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.stopBit_BLE"
													  :localdata="serial.stopBitList_BLE"
													  @change="change.stopBit_BLE"
													  :clear="false"
												></uni-data-select>
											</view>													
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">校验</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.checkout_BLE"
													  :localdata="serial.checkoutList_BLE"
													  @change="change.checkout_BLE"
													  :clear="false"
												></uni-data-select>
											</view>										
										</view>
										<view class="flex-center uni-pt-2">
											<button type="default" size="mini" @click="searchBaudRate">扫描</button>
											<button type="default" size="mini" @click="stopSearchBaudRate">停止</button>
										</view>
										<view class="uni-mt-10 uni-h5">重启设备</view>									
										<view class="uni-mt-3">
											<button type="default" size="mini" @click="check('Reset')">重启</button>
										</view>
										
									</view>
								</uni-col>
							</uni-row>
							<view class="flex-center uni-pt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>															
							</view>
						</uni-card>					
					</scroll-view>				
				</swiper-item>
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true" >					
						<view>
							<uni-card margin="3px" spacing="0" padding="3px">
								<view class="flex-center">
									<uni-data-checkbox mode="button" v-model="analog.range" :multiple="false" :localdata="analog.rangeList" />
								</view>						
								<view class="">
									<uni-row>
										<uni-col :span="17">
											<view class="flex-center uni-h2">
												<view class="">通道1</view>									
												<view class="flex-1 background-color uni-radius text-center uni-ma-2">{{analog.ad0}}</view>
												<view v-if="analog.range == 0" class="">{{analog.analogUnit[analog.ad0_mode]}}</view>							
											</view>
											<view class="flex-center uni-h2">
												<view class="">通道2</view>
												<view class="flex-1 background-color uni-radius text-center uni-ma-2">{{analog.ad1}}</view>
												<view v-if="analog.range == 0" class="">{{analog.analogUnit[analog.ad1_mode]}}</view>
											</view>	
											<view class="flex-center uni-h2">
												<view class="">通道3</view>									
												<view class="flex-1 background-color uni-radius text-center uni-ma-2">{{analog.ad2}}</view>
												<view v-if="analog.range == 0" class="">{{analog.analogUnit[analog.ad2_mode]}}</view>							
											</view>
											<view class="flex-center uni-h2">
												<view class="">通道4</view>
												<view class="flex-1 background-color uni-radius text-center uni-ma-2">{{analog.ad3}}</view>
												<view v-if="analog.range == 0" class="">{{analog.analogUnit[analog.ad3_mode]}}</view>
											</view>
											<view class="flex-center text-center uni-my-2">
												<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
												<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
												<button type="default" size="mini" @click="check('A_read')">读取</button>								
											</view>
										</uni-col>
										<uni-col :span="7">
											<view class="flex-center uni-mt-2">
												<view class="uni-mx-2">0:</view>
												<view class="width-2">
													<uni-data-select
														  v-model="analog.ad0_mode"
														  :localdata="analog.modeList"														 
														  :clear="false"
														  :disabled="true"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-mt-2">
												<view class="uni-mx-2">1:</view>
												<view class="width-2">
													<uni-data-select
														  v-model="analog.ad1_mode"
														  :localdata="analog.modeList"														  
														  :clear="false"
														  :disabled="true"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-mt-2">
												<view class="uni-mx-2">2:</view>
												<view class="width-2">
													<uni-data-select
														  v-model="analog.ad2_mode"
														  :localdata="analog.modeList"														  
														  :clear="false"
														  :disabled="true"
													></uni-data-select>
												</view>	
											</view>
											<view class="flex-center uni-mt-2">
												<view class="uni-mx-2">3:</view>
												<view class="width-2">
													<uni-data-select
														  v-model="analog.ad3_mode"
														  :localdata="analog.modeList"														  
														  :clear="false"
														  :disabled="true"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-mt-2">
												<button type="default" size="mini" @click="check('A_modeRead')">读取</button>
											</view>										
										</uni-col>
									</uni-row>
								</view>						
							</uni-card>
						</view>
						
					</scroll-view>				
				</swiper-item>
				<swiper-item>				
					<scroll-view class="height-1" scroll-y="true" >
						<view>
							<uni-card margin="3px" spacing="0" padding="3px">
								<view class="text-center">
									<view>										
										<uni-row>
											<uni-col :span="12">
												<view class="flex-center">
													<view class="width-1">ModbusID</view>
													<view class="width-2">
														<uni-data-select
															  v-model="serial.modbusId"
															  :localdata="serial.slave_list"															 
															  :clear="false"
														></uni-data-select>
													</view>													
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-1">校验</view>
													<view class="width-2">
														<uni-data-select
															  v-model="serial.checkout"
															  :localdata="serial.checkoutList"															 
															  :clear="false"
														></uni-data-select>
													</view>													
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-3">回复延时(ms)</view>
													<view class="width-2">												
														<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
													</view>													
												</view>
											</uni-col>
											<uni-col :span="12">
												<view class="flex-center">
													<view class="width-1">波特率</view>
													<view class="width-2">
														<uni-data-select
															  v-model="serial.baudRate"
															  :localdata="serial.baudRateList_Analog"															 
															  :clear="false"
														></uni-data-select>
													</view>														
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-1">停止位</view>
													<view class="width-2">
														<uni-data-select
															  v-model="serial.stopBit"
															  :localdata="serial.stopBitList_Analog"															 
															  :clear="false"
														></uni-data-select>
													</view>													
												</view>												
											</uni-col>
										</uni-row>
										<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
											<view>串口1配置</view>
											<button size="mini" @click="check('A_serialRead')">读取</button>
											<button size="mini" @click="check('A_serialWrite')">写入</button>											
										</view>
									</view>
									<view>										
										<uni-row>
											<uni-col :span="12">
												<view class="flex-center">
													<view class="width-1">ModbusID</view>
													<view class="width-2">
														<uni-data-select
															  v-model="serial.modbusId_2"
															  :localdata="serial.slave_list"															 
															  :clear="false"
															  :disabled="serial.follow"
														></uni-data-select>
													</view>													
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-1">校验</view>
													<view class="width-2">
														<uni-data-select
															  v-model="serial.checkout_2"
															  :localdata="serial.checkoutList"															 
															  :clear="false"
															  :disabled="serial.follow"
														></uni-data-select>
													</view>													
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-3">回复延时(ms)</view>
													<view class="width-2">
														<uni-easyinput :disabled="serial.follow" @change="change.reply2" v-model="serial.reply_2" placeholder="" :clearable="false" :inputBorder="true" type="number" />															
													</view>													
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-1">跟随配置</view>
													<view class="">
														<switch color="#007AFF" :checked="false" @change="A_serialFollow" style="transform:scale(0.7)"/>
													</view>											
												</view>
											</uni-col>
											<uni-col :span="12">
												<view class="flex-center">
													<view class="width-1">波特率</view>
													<view class="width-2">
														<uni-data-select
															  v-model="serial.baudRate_2"
															  :localdata="serial.baudRateList_Analog"															 
															  :clear="false"
															  :disabled="serial.follow"
														></uni-data-select>
													</view>														
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-1">停止位</view>
													<view class="width-2">
														<uni-data-select
															  v-model="serial.stopBit_2"
															  :localdata="serial.stopBitList_Analog"															 
															  :clear="false"
															  :disabled="serial.follow"
														></uni-data-select>
													</view>													
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-1">协议配置</view>
													<view class="width-2">
														<uni-data-select
															  v-model="serial.mode"
															  :localdata="serial.port2List"															 
															  :clear="false"
															  :disabled="serial.follow"
														></uni-data-select>
													</view>													
												</view>
											</uni-col>
										</uni-row>
										<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
											<view>串口2配置</view>
											<button size="mini" @click="check('A_serialRead2')">读取</button>
											<button size="mini" @click="check('A_serialWrite2')">写入</button>											
										</view>
									</view>
									<view>										
										<uni-row>
											<uni-col :span="12">
												<view class="flex-center">
													<view class="width-1">通道1</view>
													<view class="width-2">
														<uni-data-select
															  v-model="analog.ad0_mode"
															  :localdata="analog.modeList"															 
															  :clear="false"
														></uni-data-select>
													</view>													
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-1">通道2</view>
													<view class="width-2">
														<uni-data-select
															  v-model="analog.ad1_mode"
															  :localdata="analog.modeList"															  
															  :clear="false"
														></uni-data-select>
													</view>													
												</view>											
											</uni-col>
											<uni-col :span="12">
												<view class="flex-center">
													<view class="width-1">通道3</view>
													<view class="width-2">
														<uni-data-select
															  v-model="analog.ad2_mode"
															  :localdata="analog.modeList"															 
															  :clear="false"
														></uni-data-select>
													</view>														
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-1">通道4</view>
													<view class="width-2">
														<uni-data-select
															  v-model="analog.ad3_mode"
															  :localdata="analog.modeList"															  
															  :clear="false"
														></uni-data-select>
													</view>													
												</view>											
											</uni-col>
										</uni-row>
										<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
											<view>通道量程配置</view>
											<button size="mini" @click="check('A_modeRead')">读取</button>
											<button size="mini" @click="check('A_modeWrite')">写入</button>											
										</view>
									</view>
									<view>										
										<uni-row>
											<uni-col :span="12">
												<view class="flex-center">
													<view class="width-1">通道1</view>
													<view class="width-2">
														<uni-data-select
															  v-model="analog.ad0_out"
															  :localdata="analog.outputRange"															  
															  :clear="false"
														></uni-data-select>
													</view>													
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-1">通道2</view>
													<view class="width-2">
														<uni-data-select
															  v-model="analog.ad1_out"
															  :localdata="analog.outputRange"															 
															  :clear="false"
														></uni-data-select>
													</view>													
												</view>											
											</uni-col>
											<uni-col :span="12">
												<view class="flex-center">
													<view class="width-1">通道3</view>
													<view class="width-2">
														<uni-data-select
															  v-model="analog.ad2_out"
															  :localdata="analog.outputRange"															  
															  :clear="false"
														></uni-data-select>
													</view>														
												</view>
												<view class="flex-center uni-mt-2">
													<view class="width-1">通道4</view>
													<view class="width-2">
														<uni-data-select
															  v-model="analog.ad3_out"
															  :localdata="analog.outputRange"															  
															  :clear="false"
														></uni-data-select>
													</view>													
												</view>											
											</uni-col>
										</uni-row>
										<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
											<view>通道输出配置</view>
											<button size="mini" @click="check('A_outputRead')">读取</button>
											<button size="mini" @click="check('A_outputWrite')">写入</button>											
										</view>
									</view>
									<view>										
										<view class="flex-center">
											<view class="width-4">上传频率(Hz)</view>
											<view class="width-2">
												<uni-easyinput v-model="serial.uploadFrequency" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
											</view>													
										</view>
										<view class="flex-center uni-mt-2">
											<view class="width-4">AD0低通截止频率(Hz)</view>
											<view class="width-2">
												<uni-easyinput v-model="analog.offFrequency_AD0" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
											</view>													
										</view>
										<view class="flex-center uni-mt-2">
											<view class="width-4">AD1低通截止频率(Hz)</view>
											<view class="width-2">
												<uni-easyinput v-model="analog.offFrequency_AD1" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
											</view>													
										</view>
										<view class="flex-center uni-mt-2">
											<view class="width-4">AD2低通截止频率(Hz)</view>
											<view class="width-2">
												<uni-easyinput v-model="analog.offFrequency_AD2" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
											</view>													
										</view>
										<view class="flex-center uni-mt-2">
											<view class="width-4">AD3低通截止频率(Hz)</view>
											<view class="width-2">
												<uni-easyinput v-model="analog.offFrequency_AD3" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
											</view>													
										</view>										
										<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
											<view>频率配置</view>
											<button size="mini" @click="check('A_frequencyRead')">读取</button>
											<button size="mini" @click="check('A_frequencyWrite')">写入</button>											
										</view>
									</view>
								</view>
							</uni-card>
						</view>
						
					</scroll-view>				
				</swiper-item>	
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true" >
						<view>
							<uni-card margin="3px" spacing="0" padding="3px">
								<view class="flex-center">
									<view>通道1校准</view>
									<view class="width-2">
										<uni-data-select
											  v-model="analog.ad0_mode"
											  :localdata="analog.modeList"											 
											  :clear="false"
											  :disabled="true"
										></uni-data-select>
									</view>	
									<view class="flex-center uni-ml-2">
										<switch color="#007AFF" :checked="false" @change="A_checkAll" style="transform:scale(0.7)" />
										<view class="">全部校准</view>
									</view>
								</view>	
								<view class="text-center">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">校准值1</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad0_mode == 0" v-model="analog.ad0_real1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad0_mode == 1" v-model="analog.ad0_real1_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校准值2</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad0_mode == 0" v-model="analog.ad0_real2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad0_mode == 1" v-model="analog.ad0_real2_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">增益k</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad0_mode == 0" v-model="analog.ad0_k" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad0_mode == 1" v-model="analog.ad0_k_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">零偏b</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad0_mode == 0" v-model="analog.ad0_b" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad0_mode == 1" v-model="analog.ad0_b_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
										</uni-col>
									</uni-row>									
									<view class="flex-center uni-mt-2">
										<button size="mini" @click="check('ad0_sample1')">校准1</button>
										<button size="mini" @click="check('ad0_sample2')">校准2</button>
										<button size="mini" @click="check('ad0_read')">读取</button>
										<button size="mini" @click="check('ad0_write')">写入</button>
									</view>
								</view>						
							</uni-card>
							<uni-card margin="3px" spacing="0" padding="3px">
								<uni-row>
									<uni-col :span="14">
										<view class="flex-center">
											<view>通道2校准</view>
											<view class="width-2 uni-pl-11">
												<uni-data-select
													  v-model="analog.ad1_mode"
													  :localdata="analog.modeList"													  
													  :clear="false"
													  :disabled="true"
												></uni-data-select>
											</view>
										</view>
									</uni-col>									
								</uni-row>								
								<view class="text-center">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">校准值1</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad1_mode == 0" v-model="analog.ad1_real1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad1_mode == 1" v-model="analog.ad1_real1_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校准值2</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad1_mode == 0" v-model="analog.ad1_real2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad1_mode == 1" v-model="analog.ad1_real2_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">增益k</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad1_mode == 0" v-model="analog.ad1_k" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad1_mode == 1" v-model="analog.ad1_k_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">零偏b</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad1_mode == 0" v-model="analog.ad1_b" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad1_mode == 1" v-model="analog.ad1_b_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
										</uni-col>
									</uni-row>									
									<view class="flex-center uni-mt-2">
										<button size="mini" @click="check('ad1_sample1')">校准1</button>
										<button size="mini" @click="check('ad1_sample2')">校准2</button>
										<button size="mini" @click="check('ad1_read')">读取</button>
										<button size="mini" @click="check('ad1_write')">写入</button>
									</view>
								</view>						
							</uni-card>
							<uni-card margin="3px" spacing="0" padding="3px">
								<uni-row>
									<uni-col :span="14">
										<view class="flex-center">
											<view>通道3校准</view>
											<view class="width-2 uni-pl-11">
												<uni-data-select
													  v-model="analog.ad2_mode"
													  :localdata="analog.modeList"													 
													  :clear="false"
													  :disabled="true"
												></uni-data-select>
											</view>
										</view>
									</uni-col>									
								</uni-row>								
								<view class="text-center">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">校准值1</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad2_mode == 0" v-model="analog.ad2_real1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad2_mode == 1" v-model="analog.ad2_real1_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校准值2</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad2_mode == 0" v-model="analog.ad2_real2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad2_mode == 1" v-model="analog.ad2_real2_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">增益k</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad2_mode == 0" v-model="analog.ad2_k" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad2_mode == 1" v-model="analog.ad2_k_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">零偏b</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad2_mode == 0" v-model="analog.ad2_b" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad2_mode == 1" v-model="analog.ad2_b_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
										</uni-col>
									</uni-row>									
									<view class="flex-center uni-mt-2">
										<button size="mini" @click="check('ad2_sample1')">校准1</button>
										<button size="mini" @click="check('ad2_sample2')">校准2</button>
										<button size="mini" @click="check('ad2_read')">读取</button>
										<button size="mini" @click="check('ad2_write')">写入</button>
									</view>
								</view>						
							</uni-card>
							<uni-card margin="3px" spacing="0" padding="3px">
								<uni-row>
									<uni-col :span="14">
										<view class="flex-center">
											<view>通道4校准</view>
											<view class="width-2 uni-pl-11">
												<uni-data-select
													  v-model="analog.ad3_mode"
													  :localdata="analog.modeList"													  
													  :clear="false"
													  :disabled="true"
												></uni-data-select>
											</view>
										</view>
									</uni-col>									
								</uni-row>								
								<view class="text-center">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">校准值1</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad3_mode == 0" v-model="analog.ad3_real1" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad3_mode == 1" v-model="analog.ad3_real1_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校准值2</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad3_mode == 0" v-model="analog.ad3_real2" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad3_mode == 1" v-model="analog.ad3_real2_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">增益k</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad3_mode == 0" v-model="analog.ad3_k" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad3_mode == 1" v-model="analog.ad3_k_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">零偏b</view>
												<view class="width-2">
													<uni-easyinput v-if="analog.ad3_mode == 0" v-model="analog.ad3_b" placeholder="" :clearable="false" :inputBorder="true" type="text" />
													<uni-easyinput v-else-if="analog.ad3_mode == 1" v-model="analog.ad3_b_A" placeholder="" :clearable="false" :inputBorder="true" type="text" />
												</view>													
											</view>
										</uni-col>
									</uni-row>									
									<view class="flex-center uni-mt-2">
										<button size="mini" @click="check('ad3_sample1')">校准1</button>
										<button size="mini" @click="check('ad3_sample2')">校准2</button>
										<button size="mini" @click="check('ad3_read')">读取</button>
										<button size="mini" @click="check('ad3_write')">写入</button>
									</view>
								</view>						
							</uni-card>					
						</view>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 液冷 -->
		<view v-else-if="global.board == '液冷'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_D" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
							<scroll-view class="device_list" scroll-y scroll-with-animation>
							  <view
							    v-for="(item, index) in blue.devices"
							    :key="index"
							    :data-device-id="item.deviceId"
							    :data-name="item.name || item.localName"
							    @click="bleService.createBLEConnection($event)"
							    class="device_item"
							    hover-class="device_item_hover"
								>							    
								<view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
							    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
								</view>
							  </view>
							</scroll-view>
							<view class="flex-center uni-mt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>							
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>							
							</view>
						</uni-card>
					</view>				
				</swiper-item>
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true" >					
						<view>
							<uni-card margin="3px" spacing="0" padding="0px">
								<uni-data-checkbox width="230rpx"  v-model="liquidCool.warn" :multiple="true" :localdata="liquidCool.warnList" mode="default"/>
								<view class="flex-center uni-mb-1">
									<button type="default" size="mini" @click="check('L_clearwran')">故障清除</button>
								</view>
							</uni-card>
							<uni-card margin="3px" spacing="0" padding="3px">
								<view class="flex-center">									
									<uni-data-checkbox mode="button" v-model="liquidCool.run" :multiple="false" :localdata="liquidCool.runList" />
								</view>
								<uni-row>
									<uni-col :span="11">
										<view class="flex-center uni-h5">
											<view class="">模式</view>									
											<view class="card-list-show-m">{{liquidCool.runmode}}</view>
										</view>
										<view class="flex-center uni-h5">
											<view class="">错误码</view>									
											<view class="card-list-show-m">{{liquidCool.warn}}</view>
										</view>
										<view class="flex-center uni-h5">
											<view class="">流量(L/min)</view>									
											<view class="card-list-show-m">{{liquidCool.flow}}</view>										
										</view>
										<view class="flex-center uni-h5">
											<view class="">压力1(KPa)</view>									
											<view class="card-list-show-m">{{liquidCool.press1}}</view>										
										</view>
										<view class="flex-center uni-h5">
											<view class="">压力2(KPa)</view>									
											<view class="card-list-show-m">{{liquidCool.press2}}</view>										
										</view>									
										<view class="flex-center uni-h5">
											<view class="">进液温度(℃)</view>									
											<view class="card-list-show-m">{{liquidCool.temp1}}</view>										
										</view>
										<view class="flex-center uni-h5">
											<view class="">出液温度(℃)</view>									
											<view class="card-list-show-m">{{liquidCool.temp2}}</view>										
										</view>
										<view class="flex-center uni-h5">
											<view class="">环境温度(℃)</view>									
											<view class="card-list-show-m">{{liquidCool.temp3}}</view>										
										</view>
									</uni-col>
									<uni-col :span="13">
										<view class="flex-center uni-h5">
											<view class="">系统状态</view>									
											<view class="card-list-show-m">{{liquidCool.State}}</view>
										</view>									
										<view class="flex-center uni-h5">
											<view class="">泵转速(rpm)</view>									
											<view class="card-list-show-m">{{liquidCool.speed_pump}}</view>										
										</view>
										<view class="flex-center uni-h5">
											<view class="">风扇1转速(rpm)</view>									
											<view class="card-list-show-m">{{liquidCool.speed_fan1}}</view>										
										</view>
										<view class="flex-center uni-h5">
											<view class="">风扇2转速(rpm)</view>									
											<view class="card-list-show-m">{{liquidCool.speed_fan2}}</view>										
										</view>
										<view class="flex-center uni-h5">
											<view class="">风扇3转速(rpm)</view>									
											<view class="card-list-show-m">{{liquidCool.speed_fan3}}</view>										
										</view>
										
										<view class="flex-center uni-h5">
											<view class="">泵PWM(%)</view>									
											<view class="card-list-show-m">{{liquidCool.pwm_pump}}</view>										
										</view>
										<view class="flex-center uni-h5">
											<view class="">风扇PWM(%)</view>									
											<view class="card-list-show-m">{{liquidCool.pwm_fan}}</view>										
										</view>
									</uni-col>
								</uni-row>							
								<view class="flex-center uni-mt-1">
									<button v-if="autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
									<button v-else type="default" size="mini" @click="check('autoRead')">自动读取</button>
									<button type="default" size="mini" @click="check('L_read')">读取</button>																	
								</view>											
							</uni-card>						
						</view>
					</scroll-view>				
				</swiper-item>
				<swiper-item>				
					<scroll-view class="height-1" scroll-y="true" >
						<view>
							<uni-card margin="3px" spacing="0" padding="3px">							
								<uni-row>
									<uni-col :span="18">
										<view class="flex-center text-center">
											<view class="width-1">调试模式</view>
											<view class="">
												<uni-data-checkbox mode="button" v-model="liquidCool.debug" :multiple="false" :localdata="liquidCool.debugList" />
											</view>											
										</view>
										<view class="flex-center text-center">
											<view class="width-1">泵占空比</view>
											<view class="">
												<uni-easyinput v-model="liquidCool.pump_set_D" placeholder="" :clearable="false" :inputBorder="true" type="number" />
											</view>													
										</view>
										<view class="flex-center text-center uni-mt-1">
											<view class="width-1">风扇占空比</view>
											<view class="">
												<uni-easyinput v-model="liquidCool.fan_set_D" placeholder="" :clearable="false" :inputBorder="true" type="number" />
											</view>													
										</view>
									</uni-col>
									<uni-col :span="6">
										<view class="flex-column text-center uni-mt-2">
											<view class="uni-my-2">
												<button size="mini" @click="check('L_debugRead')">读取</button>
											</view>
											<view class="uni-my-2">
												<button size="mini" @click="check('L_debugWrite')">写入</button>
											</view>
																						
										</view>
									</uni-col>								
								</uni-row>								
							</uni-card>
							<uni-card margin="3px" spacing="0" padding="3px">
								<view class="text-center">								
									<view class="">									
										<uni-row>
											<uni-col :span="12">
												<view class="flex-center">
													<view class="width-2">PWM频率Hz</view>
													<view class="width-2">
														<uni-easyinput v-model="liquidCool.pwm1_Freq" placeholder="" :clearable="false" :inputBorder="true" type="number" />
													</view>													
												</view>																					
											</uni-col>
											<uni-col :span="12">
												<view class="flex-center">
													<view class="width-2">最大压力KPa</view>
													<view class="width-2">
														<uni-easyinput v-model="liquidCool.press_Max" placeholder="" :clearable="false" :inputBorder="true" type="number" />
													</view>
												</view>
												<view class="flex-center uni-mt-1">
													<view class="width-2">最小流量L/min</view>
													<view class="width-2">
														<uni-easyinput v-model="liquidCool.flow_min" placeholder="" :clearable="false" :inputBorder="true" type="number" />
													</view>													
												</view>													
											</uni-col>
										</uni-row>
										<uni-row>
											<uni-col :span="12">
												<uni-card margin="1px" spacing="0" padding="1px">
													<view class="flex-center">
														<view class="width-2">温度1(℃)</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.temp_set1" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">泵占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.pump_set1" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">风扇占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.fan_set1" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
												</uni-card>
												<uni-card margin="1px" spacing="0" padding="1px">
													<view class="flex-center">
														<view class="width-2">温度3(℃)</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.temp_set3" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">泵占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.pump_set3" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">风扇占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.fan_set3" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
												</uni-card>
												<uni-card margin="1px" spacing="0" padding="1px">
													<view class="flex-center">
														<view class="width-2">温度5(℃)</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.temp_set5" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">泵占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.pump_set5" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">风扇占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.fan_set5" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
												</uni-card>
												<uni-card margin="1px" spacing="0" padding="1px">
													<view class="flex-center">
														<view class="width-2">温度7(℃)</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.temp_set7" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">泵占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.pump_set7" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">风扇占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.fan_set7" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
												</uni-card>
												<uni-card margin="1px" spacing="0" padding="1px">
													<view class="flex-center">
														<view class="width-2">温度9(℃)</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.temp_set9" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">泵占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.pump_set9" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">风扇占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.fan_set9" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
												</uni-card>
											</uni-col>
											<uni-col :span="12">
												<uni-card margin="1px" spacing="0" padding="1px">
													<view class="flex-center">
														<view class="width-2">温度2(℃)</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.temp_set2" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">泵占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.pump_set2" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">风扇占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.fan_set2" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
												</uni-card>
												<uni-card margin="1px" spacing="0" padding="1px">
													<view class="flex-center">
														<view class="width-2">温度4(℃)</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.temp_set4" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">泵占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.pump_set4" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">风扇占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.fan_set4" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
												</uni-card>
												<uni-card margin="1px" spacing="0" padding="1px">
													<view class="flex-center">
														<view class="width-2">温度6(℃)</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.temp_set6" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">泵占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.pump_set6" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">风扇占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.fan_set6" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
												</uni-card>
												<uni-card margin="1px" spacing="0" padding="1px">
													<view class="flex-center">
														<view class="width-2">温度8(℃)</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.temp_set8" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">泵占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.pump_set8" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">风扇占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.fan_set8" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
												</uni-card>
												<uni-card margin="1px" spacing="0" padding="1px">
													<view class="flex-center">
														<view class="width-2">温度10(℃)</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.temp_set10" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">泵占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.pump_set10" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
													<view class="flex-center uni-mt-1">
														<view class="width-2">风扇占空比</view>
														<view class="width-2">
															<uni-easyinput v-model="liquidCool.fan_set10" placeholder="" :clearable="false" :inputBorder="true" type="number" />
														</view>													
													</view>
												</uni-card>
											</uni-col>
										</uni-row>
										<view class="flex-center uni-mt-1">
											<button size="mini" @click="check('L_configRead')">读取</button>
											<button size="mini" @click="check('L_configWrite')">写入</button>											
										</view>
									</view>								
								</view>
							</uni-card>
						</view>
					</scroll-view>				
				</swiper-item>				
			</swiper>
		</view>
		<!-- 编码器 -->
		<view v-else-if="global.board == '编码器'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_F" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>	
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<uni-row>
								<uni-col :span="12">
									<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
									<scroll-view class="device_list" scroll-y scroll-with-animation>
									  <view
									    v-for="(item, index) in blue.devices"
									    :key="index"
									    :data-device-id="item.deviceId"
									    :data-name="item.name || item.localName"
									    @click="bleService.createBLEConnection($event)"
									    class="device_item"
									    hover-class="device_item_hover"
										>
									    <view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
									    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
										</view>
									  </view>
									</scroll-view>								
								</uni-col>
								<uni-col :span="12">
									<view class="text-center">
										<text class="uni-h5">蓝牙配置</text>
										<view class="flex-center">
											<view class="width-1 uni-h5">波特率</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.baudRate_BLE"
													  :localdata="serial.baudRateList_BLE"
													  @change="change.baudRate_BLE"
													  :clear="false"
												></uni-data-select>
											</view>														
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">停止位</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.stopBit_BLE"
													  :localdata="serial.stopBitList_BLE"
													  @change="change.stopBit_BLE"
													  :clear="false"
												></uni-data-select>
											</view>													
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">校验</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.checkout_BLE"
													  :localdata="serial.checkoutList_BLE"
													  @change="change.checkout_BLE"
													  :clear="false"
												></uni-data-select>
											</view>										
										</view>
										<view class="flex-center uni-pt-2">
											<button type="default" size="mini" @click="searchBaudRate">扫描</button>
											<button type="default" size="mini" @click="stopSearchBaudRate">停止</button>
										</view>										
									</view>
								</uni-col>
							</uni-row>
							<view class="flex-center uni-pt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>														
							</view>
						</uni-card>
					</view>
				</swiper-item>								
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">						
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-row>
								<uni-col :span="16">
									<view class="flex-center uni-h5 text-center">
										<view class="width-2">输入速度</view>									
										<view class="card-list-show-m">{{encoder.speed_I}}</view>
										<view style="width: 40rpx;">rpm</view>
									</view>
									<view class="flex-center uni-h5 text-center">
										<view class="width-2">输入角度</view>									
										<view class="card-list-show-m">{{encoder.angular_I}}</view>
										<view style="width: 40rpx;">°</view>
									</view>
									<view class="flex-center uni-h5 text-center">
										<view class="width-2">输出角度</view>									
										<view class="card-list-show-m">{{encoder.angular_O}}</view>
										<view style="width: 40rpx;">°</view>
									</view>									
									<view class="flex-center uni-h5 text-center">
										<view class="width-2">输出角度差</view>									
										<view class="card-list-show-m">{{encoder.angular_E}}</view>
										<view style="width: 40rpx;">°</view>
									</view>
								</uni-col>
								<uni-col :span="8">
									<view class="flex-column text-center uni-mt-8">
										<view>
											<button v-if="global.autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
											<button v-else type="default" size="mini" @click="autoRead">自动读取</button>
										</view>
										<view>
											<button type="default" size="mini" @click="encoderFunc.read">读取</button>
										</view>																															
									</view>
								</uni-col>
							</uni-row>								
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-row>
								<uni-col :span="13">													
									<view class="flex-center text-center">
										<view class="width-4">输入编码器线数</view>
										<view class="width-2">
											<uni-easyinput v-model="encoder.pulseSet_I" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
										</view>													
									</view>	
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-4">输出编码器线数</view>
										<view class="width-2">
											<uni-easyinput v-model="encoder.pulseSet_O" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
										</view>													
									</view>	
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-4">角度误差范围</view>
										<view class="width-2">
											<uni-easyinput v-model="encoder.angularRange_E" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
										</view>													
									</view>
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-4">速度范围</view>
										<view class="width-2">
											<uni-easyinput v-model="encoder.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
										</view>													
									</view>																				
								</uni-col>
								<uni-col :span="11">
									<view class="flex-center text-center">
										<view class="width-2">整体符号</view>
										<view class="width-2">
											<uni-data-select
												  v-model="encoder.sign_A"
												  :localdata="encoder.signList"												  
												  :clear="false"
											></uni-data-select>
										</view>													
									</view>
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-2">输出符号</view>
										<view class="width-2">
											<uni-data-select
												  v-model="encoder.sign_O"
												  :localdata="encoder.signList"												  
												  :clear="false"
											></uni-data-select>
										</view>													
									</view>
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-2">减速比分子</view>
										<view class="width-2">
											<uni-easyinput v-model="encoder.reduct_M" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
										</view>													
									</view>
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-2">减速比分母</view>
										<view class="width-2">
											<uni-easyinput v-model="encoder.reduct_D" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
										</view>													
									</view>
									
								</uni-col>
							</uni-row>
							<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
								<view>传感器配置</view>
								<button size="mini" @click="encoderFunc.sensorRead">读取</button>
								<button size="mini" @click="encoderFunc.sensorWrite">写入</button>							
								<button size="mini" @click="encoderFunc.save">保存</button>
							</view>						
						</uni-card>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		<!-- ZDBL -->
		<view v-else-if="global.board == 'ZDBL'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_B" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>	
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<uni-row>
								<uni-col :span="12">
									<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
									<scroll-view class="device_list" scroll-y scroll-with-animation>
									  <view
									    v-for="(item, index) in blue.devices"
									    :key="index"
									    :data-device-id="item.deviceId"
									    :data-name="item.name || item.localName"
									    @click="bleService.createBLEConnection($event)"
									    class="device_item"
									    hover-class="device_item_hover"
										>
									    <view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
									    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
										</view>
									  </view>
									</scroll-view>								
								</uni-col>
								<uni-col :span="12">
									<view class="text-center">
										<text class="uni-h5">蓝牙配置</text>
										<view class="flex-center">
											<view class="width-1 uni-h5">波特率</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.baudRate_BLE"
													  :localdata="serial.baudRateList_BLE"
													  @change="change.baudRate_BLE"
													  :clear="false"
												></uni-data-select>
											</view>														
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">停止位</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.stopBit_BLE"
													  :localdata="serial.stopBitList_BLE"
													  @change="change.stopBit_BLE"
													  :clear="false"
												></uni-data-select>
											</view>													
										</view>
										<view class="flex-center uni-pt-1">
											<view class="width-1 uni-h5">校验</view>
											<view class="width-2">
												<uni-data-select
													  v-model="serial.checkout_BLE"
													  :localdata="serial.checkoutList_BLE"
													  @change="change.checkout_BLE"
													  :clear="false"
												></uni-data-select>
											</view>										
										</view>
										<view class="flex-center uni-pt-2">
											<button type="default" size="mini" @click="searchBaudRate">扫描</button>
											<button type="default" size="mini" @click="stopSearchBaudRate">停止</button>
										</view>
										<view class="uni-mt-10 uni-h5">重启设备</view>									
										<view class="uni-mt-3">
											<button type="default" size="mini" @click="check('Reset')">重启</button>
										</view>
										
									</view>
								</uni-col>
							</uni-row>
							<view class="flex-center uni-pt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>														
							</view>
						</uni-card>
					</view>
				</swiper-item>								
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">						
						<uni-card margin="3px" spacing="0" padding="3px">							
							<uni-row>
								<uni-col :span="9">
									<uni-data-checkbox width="100rpx"  v-model="ZDBL.warn" :multiple="true" :localdata="ZDBL.warnList" mode="default"/>
									<button class="uni-px-4" type="default" size="mini" @click="ZDBLFunc.clearWarn">故障清除</button>
								</uni-col>
								<uni-col :span="15">
									<view class="flex-center text-center">
										<view class="width-2">控制模式</view>
										<view class="width-3">
											<uni-data-select
												  v-model="ZDBL.runMode"
												  :localdata="ZDBL.rumModeList"												  
												  :clear="false"
											></uni-data-select>
										</view>													
									</view>
									<view v-if="ZDBL.runMode == 0" class="flex-center text-center uni-mt-2">
										<view class="width-2">占空比%</view>
										<uni-number-box width="55" v-model="ZDBL.param_PWM" @change="change.PWM" />													
									</view>
									<view v-else-if="ZDBL.runMode == 1" class="flex-center text-center uni-mt-2">
										<view class="width-2">电压给定V</view>
										<uni-number-box width="55" v-model="ZDBL.param_voltage" @change="change.PWM" />													
									</view>
									<view v-else-if="ZDBL.runMode == 2" class="flex-center text-center uni-mt-2">
										<view class="width-2">电流给定A</view>
										<uni-number-box width="55" v-model="ZDBL.param_current" @change="change.PWM" />													
									</view>
									<view v-else-if="ZDBL.runMode == 3" class="flex-center text-center uni-mt-2">
										<view class="width-2">转速给定rpm</view>
										<uni-number-box width="55" v-model="ZDBL.param_speed" @change="change.PWM" />													
									</view>
									<view v-else-if="ZDBL.runMode == 4" class="flex-center text-center uni-mt-2">
										<view class="width-2">位置给定</view>
										<uni-number-box width="55" v-model="ZDBL.param_position_A" @change="change.PWM" />													
									</view>
									<view v-else-if="ZDBL.runMode == 5" class="flex-center text-center uni-mt-2">
										<view class="width-2">位置增量</view>
										<uni-number-box width="55" v-model="ZDBL.param_position_R" @change="change.PWM" />													
									</view>
									<view v-else-if="ZDBL.runMode == 6" class="flex-center text-center uni-mt-2">
										<view class="width-2">负载给定A</view>
										<uni-number-box width="55" v-model="ZDBL.param_load" @change="change.PWM" />													
									</view>
									<view v-else-if="ZDBL.runMode == 7" class="flex-center text-center uni-mt-2">
										<view class="width-2">负载给定A</view>
										<uni-number-box width="55" v-model="ZDBL.param_regenrative_brake" @change="change.PWM" />													
									</view>
									<view v-else-if="ZDBL.runMode == 8" class="flex-column">
										<view class="flex-center text-center uni-mt-2">
											<view class="width-2">目标速度rpm</view>
											<uni-number-box width="55" v-model="ZDBL.param_accelerate_speed" @change="change.PWM" />
										</view>
										<view class="flex-center text-center uni-mt-2">
											<view class="width-2">最大速度rpm</view>
											<uni-number-box width="55" v-model="ZDBL.speedMax" @change="change.PWM" />
										</view>
										<view class="flex-center text-center uni-mt-2">
											<view class="width-2">加速时间s</view>
											<uni-number-box width="55" v-model="ZDBL.param_accelerate_time" @change="change.PWM" />
										</view>
										<view class="flex-center text-center uni-mt-2">
											<view class="width-2">减速时间s</view>
											<uni-number-box width="55" v-model="ZDBL.param_decelerate_time" @change="change.PWM" />
										</view>
									</view>
									<view class="flex-center">
										<uni-data-checkbox mode="button" v-model="ZDBL.run" :multiple="false" :localdata="ZDBL.runList" />
									</view>
									<view class="flex-center text-center">
										<view style="width: 80rpx;">电压</view>									
										<view class="card-list-show-m">{{ZDBL.voltage}}</view>
										<view style="width: 60rpx;">V</view>
									</view>
									<view class="flex-center text-center">
										<view style="width: 80rpx;">电流</view>									
										<view class="card-list-show-m">{{ZDBL.current}}</view>
										<view style="width: 60rpx;">A</view>
									</view>
									<view class="flex-center text-center">
										<view style="width: 80rpx;">功率</view>									
										<view class="card-list-show-m">{{ZDBL.power}}</view>
										<view style="width: 60rpx;">W</view>
									</view>
									<view class="flex-center text-center">
										<view style="width: 80rpx;">速度</view>									
										<view class="card-list-show-m">{{ZDBL.speed}}</view>
										<view style="width: 60rpx;">rpm</view>
									</view>
									<view class="flex-center text-center">
										<view style="width: 80rpx;">位置</view>									
										<view class="card-list-show-m">{{ZDBL.position}}</view>
										<view style="width: 60rpx;">°</view>
									</view>
									<view class="flex-center text-center">
										<view style="width: 80rpx;">温度</view>									
										<view class="card-list-show-m">{{ZDBL.temperature}}</view>
										<view style="width: 60rpx;">℃</view>
									</view>									
									<view class="flex-center uni-mt-1">
										<button class="uni-px-4" v-if="autoread" type="default" size="mini" @click="closeRead">关闭读取</button>
										<button class="uni-px-4" v-else type="default" size="mini" @click="autoRead">自动读取</button>
										<button class="uni-px-4" type="default" size="mini" @click="ZDBLFunc.stateRead()">读取</button>																	
									</view>
								</uni-col>
							</uni-row>														
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-row>
								<uni-col :span="12">
									<view class="flex-center text-center">
										<view style="width: 145rpx;">固件版本号</view>									
										<view class="card-list-show-m">{{ZDBL.firmware}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">boot版本号</view>									
										<view class="card-list-show-m">{{ZDBL.boot}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">硬件版本号</view>									
										<view class="card-list-show-m">{{ZDBL.hardware}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">产品序列号</view>									
										<view class="card-list-show-m">{{ZDBL.serialNum}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">占空比系数</view>									
										<view class="card-list-show-m">{{ZDBL.coefficient_D}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">电压系数</view>									
										<view class="card-list-show-m">{{ZDBL.coefficient_V}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">电流系数</view>									
										<view class="card-list-show-m">{{ZDBL.coefficient_A}}</view>										
									</view>
									<view class="flex-center  text-center">
										<view style="width: 145rpx;">功率系数</view>									
										<view class="card-list-show-m">{{ZDBL.coefficient_W}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">温度系数</view>									
										<view class="card-list-show-m">{{ZDBL.coefficient_T}}</view>										
									</view>
								</uni-col>
								<uni-col :span="12">									
									<view class="flex-center text-center">
										<view style="width: 145rpx;">速度系数</view>									
										<view class="card-list-show-m">{{ZDBL.coefficient_S}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">位置系数</view>									
										<view class="card-list-show-m">{{ZDBL.coefficient_L}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">最大耐压</view>									
										<view class="card-list-show-m">{{ZDBL.voltage_max}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">最小电压</view>									
										<view class="card-list-show-m">{{ZDBL.voltage_min}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">额定电流</view>									
										<view class="card-list-show-m">{{ZDBL.current_rate}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">最大电流</view>									
										<view class="card-list-show-m">{{ZDBL.current_max}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">最高温度</view>									
										<view class="card-list-show-m">{{ZDBL.temperature_max}}</view>										
									</view>
									<view class="flex-center text-center">
										<view style="width: 145rpx;">最小温度</view>									
										<view class="card-list-show-m">{{ZDBL.temperature_min}}</view>										
									</view>
									<view class="flex-center text-center">
										<button type="default" size="mini" @click="ZDBLFunc.basicRead()">读取</button>										
									</view>
								</uni-col>
							</uni-row>							
						</uni-card>
					</scroll-view>
				</swiper-item>
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">
						<uni-card margin="3px" spacing="0" padding="3px">
							<view class="text-center">								
								<uni-group title="串口1配置">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">ModbusID</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.modbusId"
														  :localdata="serial.slave_list"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校验</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.checkout"
														  :localdata="serial.checkoutList"														  
														  :clear="false"
													></uni-data-select>
												</view>
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">回复延时(ms)</view>
												<view class="width-2">												
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">波特率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.baudRate"
														  :localdata="serial.baudRateList_Analog"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">停止位</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.stopBit"
														  :localdata="serial.stopBitList_Analog"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view class="">串口1配置</view>
										<button size="mini" @click="check('serialRead')">读取</button>
										<button size="mini" @click="check('serialWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="串口2配置">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center">
												<view class="width-1">ModbusID</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.modbusId_2"
														  :localdata="serial.slave_list"														  
														  :clear="false"
														  :disabled="true"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">校验</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.checkout_2"
														  :localdata="serial.checkoutList"														 
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">回复延时(ms)</view>
												<view class="width-2">												
													<uni-easyinput @change="change.reply2" v-model="serial.reply_2" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
											<view class="flex-center uni-mt-2">
												<view class="width-1">跟随配置</view>
												<view class="">
													<switch color="#007AFF" :checked="false" @change="A_serialFollow" style="transform:scale(0.7)"/>
												</view>											
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center">
												<view class="width-1">波特率</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.baudRate_2"
														  :localdata="serial.baudRateList_Analog"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">停止位</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.stopBit_2"
														  :localdata="serial.stopBitList_Analog"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">串口2功能</view>
												<view class="width-2">
													<uni-data-select
														  v-model="serial.port2"
														  :localdata="serial.port2List"														  
														  :clear="false"
													></uni-data-select>
												</view>													
											</view>											
										</uni-col>									
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view class="">串口2配置</view>
										<button size="mini" @click="check('serialRead2')">读取</button>
										<button size="mini" @click="check('serialWrite2')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="模拟输入配置">
									<uni-row>
										<uni-col :span="12">													
											<view class="flex-center">
												<view class="width-3">最小值</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.torqueRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>	
											<view class="flex-center uni-pt-1">
												<view class="width-3">最大值</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>																																
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-3">中间值</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.angleRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">死区</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.decimal_T" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>模拟输入配置</view>
										<button size="mini" @click="check('TSAFunc.sensorRead')">读取</button>
										<button size="mini" @click="check('TSAFunc.sensorWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="输入配置">
									<uni-row>
										<uni-col :span="12">													
											<view class="flex-center">
												<view class="width-1">输入源</view>
												<view class="width-3">
													<uni-data-select
														  v-model="ZDBL.source_IN"
														  :localdata="ZDBL.sourceList_IN"														  
														  :clear="false"														  
													></uni-data-select>
												</view>													
											</view>	
											<view class="flex-center uni-pt-1">
												<view class="width-1">方向源</view>
												<view class="width-3">
													<uni-data-select
														  v-model="ZDBL.source_DIR"
														  :localdata="ZDBL.sourceList_DIR"														  
														  :clear="false"														  
													></uni-data-select>
												</view>													
											</view>											
											<view class="flex-center uni-pt-1">
												<view class="width-3">贝塞尔曲线</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">3段曲线速度</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">3段曲线加速度</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">启动源</view>
												<view class="width-3">
													<uni-data-select
														  v-model="ZDBL.source_start"
														  :localdata="ZDBL.sourceList_start"														  
														  :clear="false"														  
													></uni-data-select>
												</view>														
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-1">输入轨迹</view>
												<view class="width-3">
													<uni-data-select
														  v-model="ZDBL.track"
														  :localdata="ZDBL.trackList"														  
														  :clear="false"														  
													></uni-data-select>
												</view>														
											</view>
											<view class="flex-center">
												<view class="width-3">低通带宽</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.torqueRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
												</view>													
											</view>	
											<view class="flex-center uni-pt-1">
												<view class="width-3">线性斜率</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">线性时间</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>输入配置</view>
										<button size="mini" @click="check('TSAFunc.sensorRead')">读取</button>
										<button size="mini" @click="check('TSAFunc.sensorWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
							</view>									
							<view class="flex-center">
								<button size="mini" @click="check('TSAFunc.configRead')">全读</button>
								<button size="mini" @click="check('TSAFunc.configWrite')">全写</button>							
								<button size="mini" @click="check('save')">保存</button>
							</view>						
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">							
							<progress :percent="ZDBL.progress" show-info />
							<button size="mini" type="default"@click="otaUpgrader.prepareFirmware">选择固件文件</button>
							<button size="mini" type="default" @click="otaUpgrader.upgrade">开始OTA更新</button>														
						</uni-card>
					</scroll-view>
				</swiper-item>
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">
						<uni-card margin="3px" spacing="0" padding="3px">
							<view class="text-center">								
								<uni-group title="电机参数">
									<uni-row>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-1">Hall匹配表</view>
												<view class="width-2">
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
											<view class="flex-center">
												<view class="width-1">Lq</view>
												<view class="width-2">
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
											<view class="flex-center">
												<view class="width-1">Ld</view>
												<view class="width-2">
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
											<view class="flex-center">
												<view class="width-1">R</view>
												<view class="width-2">
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">											
											<view class="flex-center uni-pt-1">
												<view class="width-1">极对数</view>
												<view class="width-2">												
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
											<view class="flex-center">
												<view class="width-1">反电势常数</view>
												<view class="width-2">
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
											<view class="flex-center">
												<view class="width-1">转动惯量</view>
												<view class="width-2">
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>
											<view class="flex-center">
												<view class="width-1">粘性摩擦力</view>
												<view class="width-2">
													<uni-easyinput @change="change.reply1" v-model="serial.reply" placeholder="" :clearable="false" :inputBorder="true" type="number"/>															
												</view>													
											</view>											
										</uni-col>									
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view class="">电机参数</view>
										<button size="mini" @click="check('serialRead2')">读取</button>
										<button size="mini" @click="check('serialWrite2')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="工作参数">
									<uni-row>
										<uni-col :span="12">											
											<view class="flex-center">
												<view class="width-1">逆变模式</view>
												<view class="width-3">
													<uni-data-select
														  v-model="ZDBL.source_IN"
														  :localdata="ZDBL.sourceList_IN"														  
														  :clear="false"														  
													></uni-data-select>
												</view>													
											</view>											
											<view class="flex-center uni-pt-1">
												<view class="width-3">母线电压</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">电机电流</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">电机功率</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center">
												<view class="width-1">控制模式</view>
												<view class="width-3">
													<uni-data-select
														  v-model="ZDBL.source_IN"
														  :localdata="ZDBL.sourceList_IN"														  
														  :clear="false"														  
													></uni-data-select>
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">电机速度</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">电机位置</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">驱动器温度</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>工作参数</view>
										<button size="mini" @click="check('TSAFunc.sensorRead')">读取</button>
										<button size="mini" @click="check('TSAFunc.sensorWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="控制参数">
									<uni-row>
										<uni-col :span="12">													
											<view class="flex-center uni-pt-1">
												<view class="width-3">额定电压</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">额定电流</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">最大转速</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">刹车电阻工作电压</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
										</uni-col>
										<uni-col :span="12">
											<view class="flex-center uni-pt-1">
												<view class="width-3">过载系数</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">过载时间</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
											<view class="flex-center uni-pt-1">
												<view class="width-3">超前角</view>
												<view class="width-2">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>													
											</view>
										</uni-col>
									</uni-row>
									<view class="flex-center uni-ma-2 uni-pa-1 uni-radius background-color">
										<view>控制参数</view>
										<button size="mini" @click="check('TSAFunc.sensorRead')">读取</button>
										<button size="mini" @click="check('TSAFunc.sensorWrite')">写入</button>							
										<button size="mini" @click="check('save')">保存</button>
									</view>
								</uni-group>
								<uni-group title="PID参数">
									<view class="flex-center">
										<view style="width: 35px;">Iq:</view>
										<uni-data-checkbox  v-model="ZDBL.config_PID" :multiple="true" :localdata="ZDBL.configList_PID" @change="change.sendCycle" />
										<view style="width: 20px;">P:</view>
										<view style="width: 60px;">
											<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
										</view>
										<view style="width: 20px;">I:</view>
										<view style="width: 60px;">
											<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
										</view>
										<button class="uni-px-6" size="mini" @click="check('TSAFunc.sensorRead')">读取</button>
										<button class="uni-px-6" size="mini" @click="check('TSAFunc.sensorWrite')">写入</button>
									</view>
									<view class="flex-center uni-mt-1">
										<view style="width: 35px;">Id:</view>
										<uni-data-checkbox  v-model="ZDBL.config_PID" :multiple="true" :localdata="ZDBL.configList_PID" @change="change.sendCycle" />
										<view style="width: 20px;">P:</view>
										<view style="width: 60px;">
											<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
										</view>
										<view style="width: 20px;">I:</view>
										<view style="width: 60px;">
											<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
										</view>
										<button class="uni-px-6" size="mini" @click="check('TSAFunc.sensorRead')">读取</button>
										<button class="uni-px-6" size="mini" @click="check('TSAFunc.sensorWrite')">写入</button>
									</view>
									<view class="flex-center uni-mt-1">
										<view style="width: 35px;">速度:</view>
										<uni-data-checkbox  v-model="ZDBL.config_PID" :multiple="true" :localdata="ZDBL.configList_PID" @change="change.sendCycle" />
										<view class="flex-column">
											<view class="flex-center">
												<view style="width: 20px;">P:</view>
												<view style="width: 60px;">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>
												<view style="width: 20px;">I:</view>
												<view style="width: 60px;">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>
											</view>
											<view class="flex-center uni-mt-1">
												<view style="width: 20px;">D:</view>
												<view style="width: 60px;">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>
												<view style="width: 20px;">N:</view>
												<view style="width: 60px;">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>
											</view>
										</view>										
										<button class="uni-px-6" size="mini" @click="check('TSAFunc.sensorRead')">读取</button>
										<button class="uni-px-6" size="mini" @click="check('TSAFunc.sensorWrite')">写入</button>
									</view>
									<view class="flex-center uni-mt-1">
										<view style="width: 35px;">位置:</view>
										<uni-data-checkbox  v-model="ZDBL.config_PID" :multiple="true" :localdata="ZDBL.configList_PID" @change="change.sendCycle" />
										<view class="flex-column">
											<view class="flex-center">
												<view style="width: 20px;">P:</view>
												<view style="width: 60px;">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>
												<view style="width: 20px;">I:</view>
												<view style="width: 60px;">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>
											</view>
											<view class="flex-center uni-mt-1">
												<view style="width: 20px;">D:</view>
												<view style="width: 60px;">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>
												<view style="width: 20px;">N:</view>
												<view style="width: 60px;">
													<uni-easyinput v-model="T_S.speedRange" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
												</view>
											</view>
										</view>										
										<button class="uni-px-6" size="mini" @click="check('TSAFunc.sensorRead')">读取</button>
										<button class="uni-px-6" size="mini" @click="check('TSAFunc.sensorWrite')">写入</button>
									</view>									
								</uni-group>
							</view>									
							<view class="flex-center uni-mt-1">
								<button size="mini" @click="check('TSAFunc.configRead')">全读</button>
								<button size="mini" @click="check('TSAFunc.configWrite')">全写</button>							
								<button size="mini" @click="check('save')">保存</button>
							</view>						
						</uni-card>						
					</scroll-view>
				</swiper-item>
			</swiper>			
		</view>
		<!-- ZN-BINLC -->
		<view v-else-if="global.board == 'ZN-BINLC'">
			<view class="flex-center">
				<view v-for="(tab,index) in global.tabBars_F" :key="tab.id" :id="tab.id" :data-current="index" @click="change.ontabtap(index)">			    
					<text class="uni-main-color uni-h5 height-0" :class="global.tabIndex == index ? 'border-bottom' : ''">{{tab.name}}</text>
				</view>
			</view>	
			<swiper class="height-1 background-color" :current="global.tabIndex" :autoplay="false" :interval="3000" :duration="300" @change="change.swiper">
				<swiper-item>
					<view class="height-1">
						<uni-card margin="5px" spacing="0">
							<view class="uni-h5">已发现 {{blue.devices.length }} 个外围设备：</view>
							<scroll-view class="device_list" scroll-y scroll-with-animation>
							  <view
							    v-for="(item, index) in blue.devices"
							    :key="index"
							    :data-device-id="item.deviceId"
							    :data-name="item.name || item.localName"
							    @click="bleService.createBLEConnection($event)"
							    class="device_item"
							    hover-class="device_item_hover"
								>							    
								<view class="uni-h5" :style="{ color: converter.ab2hex(item.advertisData) == 'aa55' ? '#007aff' : '#333'}">{{ item.name }}</view>
							    <view style="font-size: 10px">信号强度: {{ item.RSSI }}dBm ({{ tool.myMax(0, item.RSSI + 100)}}%)
								</view>
							  </view>
							</scroll-view>
							<view class="flex-center uni-mt-2">
								<button type="default" size="mini" @click="bleService.openBluetoothAdapter">扫描</button>
								<button type="default" size="mini" @click="bleService.stopBluetoothDevicesDiscovery">停止</button>							
								<button v-if="blue.connected" type="default" size="mini" @click="bleService.closeBLEConnection">断开连接</button>							
							</view>
						</uni-card>
					</view>
				</swiper-item>								
				<swiper-item>
					<scroll-view class="height-1" scroll-y="true">						
						<uni-card margin="3px" spacing="0" padding="3px">
							<uni-row>
								<uni-col :span="12">													
									<view class="flex-center text-center">
										<view class="width-1">距离</view>
										<view class="card-list-show-m">{{ZN_BINLC.dis}}</view>																						
									</view>	
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-1">卡号</view>
										<view class="card-list-show-m">{{ZN_BINLC.ic}}</view>																							
									</view>	
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-1">重量(g)</view>
										<view class="card-list-show-m">{{ZN_BINLC.weight}}</view>																							
									</view>
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-1">电池电压(V)</view>
										<view class="card-list-show-m">{{ZN_BINLC.vol}}</view>																							
									</view>
								</uni-col>
								<uni-col :span="12">
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-1">错误信息</view>
										<view class="card-list-show-m">{{ZN_BINLC.msg}}</view>																							
									</view>
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-1">输出IO</view>
										<view class="card-list-show-m">{{ZN_BINLC.out}}</view>																							
									</view>
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-1">输入IO</view>
										<view class="card-list-show-m">{{ZN_BINLC.in}}</view>																							
									</view>																											
								</uni-col>
							</uni-row>
							<view class="divider uni-my-2"></view>
							<uni-row>
								<uni-col :span="18">													
									<view class="flex-center text-center">
										<view class="width-1">版本号</view>
										<view style="flex: 1;">
											<uni-easyinput @input="ZN_BINLCFunc.inputVersion()" v-model="ZN_BINLC.version" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
										</view>													
									</view>	
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-1">秘钥</view>
										<view style="flex: 1;">
											<uni-easyinput @input="ZN_BINLCFunc.inputProductKey()" v-model="ZN_BINLC.productKey" placeholder="" :clearable="false" :inputBorder="true" type="text" />																														
										</view>													
									</view>	
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-1">设备名</view>
										<view style="flex: 1;">
											<uni-easyinput @input="ZN_BINLCFunc.inputDeviceName()" v-model="ZN_BINLC.deviceName" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
										</view>													
									</view>
									<view class="flex-center uni-pt-1 text-center">
										<view class="width-1">设备密码</view>
										<view style="flex: 1;">
											<uni-easyinput @input="ZN_BINLCFunc.inputDeviceSecret()" v-model="ZN_BINLC.deviceSecret" placeholder="" :clearable="false" :inputBorder="true" type="text" />															
										</view>													
									</view>																				
								</uni-col>
								<uni-col :span="6">
									<view class="flex-column text-center uni-mt-8">
										<view>
											<button size="mini" @click="ZN_BINLCFunc.readStr()">读取</button>
										</view>
										<view>
											<button size="mini" @click="ZN_BINLCFunc.writeStr()">写入</button>
										</view>																															
									</view>																											
								</uni-col>
							</uni-row>
						</uni-card>
						<uni-card margin="3px" spacing="0" padding="3px">
							<view class="flex-center">
								<button size="mini" @click="ZN_BINLCFunc.wakeUp_btn()">按键唤醒</button>
								<button size="mini" @click="ZN_BINLCFunc.wakeUp_tim()">定时唤醒</button>
							</view>
						</uni-card>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
	</view>
	<!-- foot -->
	<view v-if="global.board !== '调试助手'" class="foot">
		<scroll-view class="data_list" scroll-y scroll-with-animation>
			<view style="display: flex;" v-for="(item,index) in blue.showData" :key="index">
				<view class="">{{item.name}}</view>
				<view class="" @click="copy(item.value)">{{item.value}}</view>
			</view>
		</scroll-view>
	</view>
</template>

<script setup>	
	import { fail } from 'assert'
	import { parameters,tool,converter,fileEncryptor} from '@/common/utils.js'
	import { onMounted, reactive, ref } from "vue"
	import { promises } from 'stream';	
	/* 蓝牙相关参数定义 */
	const blue = reactive({							//蓝牙参数
		//设备id
		deviceId:'',
		//服务id，这里根据自己的设备写死
		//特征值id-----这里根据自己的设备写死
		serviceId:'0000FFE0-0000-1000-8000-00805F9B34FB',		//HC04
		characteristicId:'0000FFE1-0000-1000-8000-00805F9B34FB',//HC04
		notifycharacteristicId:'0000FFE1-0000-1000-8000-00805F9B34FB',//HC04
		
		serviceId_HC02:'49535343-FE7D-4AE5-8FA9-9FAFD205E455',		//HC02
		characteristicId_HC02:'49535343-8841-43F4-A8D4-ECBE34729BB3',//HC02
		notifycharacteristicId_HC02:'49535343-1E4D-4BD9-BA61-23C647249616',//HC02
		
		serviceId_HC04:'0000FFE0-0000-1000-8000-00805F9B34FB',		//HC04
		characteristicId_HC04:'0000FFE1-0000-1000-8000-00805F9B34FB',//HC04
		notifycharacteristicId_HC04:'0000FFE1-0000-1000-8000-00805F9B34FB',//HC04
		
		serviceId_CH9141:'0000FFE0-0000-1000-8000-00805F9B34FB',		//CH9141
		characteristicId_CH9141:'0000FFE2-0000-1000-8000-00805F9B34FB',//CH9141
		notifycharacteristicId_CH9141:'0000FFE1-0000-1000-8000-00805F9B34FB',//CH9141		
		
		serviceId_CH9141_P:'0000FFF0-0000-1000-8000-00805F9B34FB',		//CH9141配置通道
		characteristicId_CH9141_P:'0000FFF3-0000-1000-8000-00805F9B34FB',//CH9141配置通道
		notifycharacteristicId_CH9141_P:'0000FFF3-0000-1000-8000-00805F9B34FB',//CH9141配置通道
		
		serviceId_ztble:'0000FFE0-0000-1000-8000-00805F9B34FB',		//znble		
		characteristicId_ztble:'0000FFE2-0000-1000-8000-00805F9B34FB',//znble
		notifycharacteristicId_ztble:'0000FFE1-0000-1000-8000-00805F9B34FB',//znble		
		characteristicId_ztble_P:'0000FFE3-0000-1000-8000-00805F9B34FB',//ztble
		notifycharacteristicId_ztble_P:'0000FFE3-0000-1000-8000-00805F9B34FB',//ztble
		
		//设备名称
		deviceName:'',
		//存放蓝牙设备数组
		devices: [],
		//连接的蓝牙设备
		connectDevices:[],
		//广播数据
		advertisData:'',
		//查看是否连接
		connected: false,
		//查看是否连接
		reconnected_flag: 0,
		//查看是否关闭
		closed:true,
		//存储当前连接状态，里面的value就是手机接收的值
		chs: [],
		//记录电脑向手机传递的数据
		receiveData:[],
		//查询蓝牙适配器的开始时间
		_discoveryStarted: false, 
		//是否可写
		canWrite:false,
		//要发送的数据
		sendData:'',
		//用户对设备设置的基本参数
		myData:[],
		//数据显示
		showData:[],
		//回复数据长度
		resLength:8	,
		timeout:null,
		requestQueue:[],
		currentRequest:null,
	})
	/* 全局参数定义 */
	const global = reactive({						//全局参数
		showTitle:'请开启蓝牙',
		screenHeight: 0,
		statusBarHeight: 0,
		windowHeight: 0,
		tabBars_A:[
					{name: '连接',id: 0},
					{name: '读取',id: 1},
					{name: '测试',id: 2},
					{name: '配置',id: 3},
				],
		tabBars_B:[
					{name: '连接',id: 0},
					{name: '读取',id: 1},
					{name: '外设配置',id: 2},
					{name: '参数配置',id: 3},
				],
		tabBars_C:[
					{name: '连接',id: 0},
					{name: '读取',id: 1},
					{name: '配置',id: 2},
					{name: '校准',id: 3},
				],
		tabBars_D:[
					{name: '连接',id: 0},
					{name: '读取',id: 1},
					{name: '配置',id: 2}					
				],
		tabBars_E:[
					{name: '连接',id: 0},
					{name: '通信',id: 1},
					{name: '配置',id: 2}					
				],
		tabBars_F:[
					{name: '连接',id: 0},					
					{name: '配置',id: 1}					
				],
		tabBars_G:[
					{name: '连接',id: 0},
					{name: '状态1',id: 1},
					{name: '状态2',id: 2},					
					{name: '配置',id: 3},
				],
		tabIndex:0,
		check:0,
		autoread:0,
		timer:null,
		timer_R:null,
		timeout:null,
		timestamp:null,
		board:"垃圾分类N",
		boardList:[
					{ value: "调试助手", text: "调试助手" },
					{ value: "垃圾分类", text: "垃圾分类" },
					{ value: "垃圾分类N", text: "垃圾分类N" },
					{ value: "扭矩转速", text: "扭矩转速" },
					{ value: "ZN-TSA-01", text: "ZN-TSA-01" },
					{ value: "ZN-WTA-02", text: "ZN-WTA-02" },
					{ value: "ZN-WTA-01", text: "ZN-WTA-01" },
					{ value: "ZN-RTD-01", text: "ZN-RTD-01" },
					{ value: "模拟量采集", text: "模拟量采集" },
					{ value: "液冷", text: "液冷" },
					{ value: "编码器", text: "编码器" },
					{ value: "ZDBL", text: "ZDBL" },
					{ value: "ZN-BINLC", text: "ZN-BINLC" },
				],
		writeOK:0,
		searchBaud:0,
		current:0,		
	})
	/* 调试助手 */
	const test = reactive({
		sendData:'',
		log:[],		
		time:500,
		timeMin:100,
		cycle:[],
		cycleList:[
					{ value: 0b00000001, text: "循环发送(ms)" }					
				],
		timer:null,
		TXLength:0,
		RXLength:0,
		type:[1,2,8],
		typeList:[
					{ value: 0b00000001, text: "HEX发送" },
					{ value: 0b00000010, text: "HEX接收" },
					{ value: 0b00000100, text: "时间戳" },
					{ value: 0b00001000, text: "监听" },
				]		
	})
	const testFunc = {
		formatTime:()=>{
		  const timestamp = Date.now();
		  const date = new Date(timestamp); // 毫秒级时间戳
		  const hours = String(date.getHours()).padStart(2, '0');   // 补零
		  const minutes = String(date.getMinutes()).padStart(2, '0');
		  const seconds = String(date.getSeconds()).padStart(2, '0');
		  const decimal = String(date.getMilliseconds()).padStart(3, '0');
		  return `${hours}:${minutes}:${seconds}:${decimal}`; // 输出示例：00:00:00:000
		},
		writeData:()=>{
			if(!blue.connected){
				uni.showToast({	title:'请先连接蓝牙',	icon:'none'})
				return
			}
			console.log(test.sendData,'test.sendData')
			const buffer = test.type.includes(1)?converter.hex2ab(test.sendData):converter.str2ab(test.sendData)
			console.log(buffer,'buffer')
			test.TXLength = test.TXLength + buffer.byteLength
			uni.writeBLECharacteristicValue({				//写
				deviceId: blue.deviceId,
				serviceId: blue.serviceId,
				characteristicId: blue.characteristicId,
				value: buffer,
				complete:(e)=>{
					if(test.type.includes(8)){
						global.timestamp = testFunc.formatTime();
						test.log.unshift({time:test.type.includes(4)?global.timestamp:null,name:' TX:',value:test.type.includes(1)?converter.ab2hex(buffer):converter.ab2str(buffer)});
					}
					//buffer本身是arraybuffer（arraybuffer要转换为16进制）
					console.log('手机发送的数据',test.type.includes(1)?converter.ab2hex(buffer):converter.ab2str(buffer));					
				},
				success: (res) => {				
					// 操作之前先监听，保证第一时间获取数据（value就是特征值当前最新的值）				
					uni.onBLECharacteristicValueChange((characteristic) => {
						//console.log('触发监听(onBLECharacteristicValueChange)');
						console.log(characteristic,'onBLECharacteristicValueChange')
						if(test.type.includes(8)){
							global.timestamp = testFunc.formatTime();
							test.RXLength = test.RXLength + characteristic.value.byteLength
							test.log.unshift({time:test.type.includes(4)?global.timestamp:null,name:' RX:',value:test.type.includes(2)?converter.ab2hex(characteristic.value):converter.ab2str(characteristic.value)});
						}											
					})
				},
				fail: (err) => {				
					console.log(err,'fail')								
				}
			})		
		},
		clearShowData:()=>{
			test.log.length = 0
		}
	}
	/* 串口相关参数定义 */
	const serial = reactive({
		slave_id:0,
		slaveId_last:1,
		slave_list:parameters.SLAVE_ID,
		baudRateList:parameters.BAUDRATE,		
		stopBitList:parameters.STOPBIT,
		checkoutList:parameters.CHECKOUT,
		baudRateList_Analog:parameters.BAUDRATE_ANALOG,
		stopBitList_Analog:parameters.STOPBIT_ANALOG,
		baudRateList_BLE:parameters.BAUDRATE_BLE,
		stopBitList_BLE:parameters.STOPBIT_BLE,
		checkoutList_BLE:parameters.CHECKOUT_BLE,
		modbusId:1,		
		baudRate:4,
		stopBit:0,
		checkout:0,
		reply:2,
		replyMin:0,
		replyMax:225,
		modbusId_2:1,
		baudRate_2:4,
		stopBit_2:0,
		checkout_2:0,
		reply_2:2,
		port2:0,
		port2List:[
					{ value: 0, text: "Modbus" },
					{ value: 1, text: "主动上传" },
					{ value: 2, text: "匿名协议主动上传" },
				],
		baudRate_BLE:9600,
		baudRate_BLE_last:9600,
		stopBit_BLE:1,
		stopBit_BLE_last:1,
		checkout_BLE:0,
		checkout_BLE_last:0,
		mode:0,
		follow:0,
		uploadFrequency:0,
	})

	const WTA = reactive({							//压力参数
		weight1:0,
		weight2:0,
		warnList:parameters.WARN_WTA,
		warn1:0,
		warn2:0,
		temperature1:0.0,
		temperature2:0.0,
		current1:0.0,
		current2:0.0,
		weightSet:1000,
		DACset1:0,
		DACset2:9000,
		DACReal1:null,
		DACReal2:null,
		weightRange:1000,
		weightGain:1,
		weightOffset:0,
		DACGain:1,
		DACOffset:0,
		polarity:0,
		polarityList:parameters.POLARITY,
		mult:0,
		multList:parameters.MULT,
		sampleRate:0,		
		sampleRateList01:parameters.SAMPLERATE_WTA01,
		sampleRateList02:parameters.SAMPLERATE_WTA02,
		weightUnit:2,
		weightUnitList:parameters.WEIGHTUNIT,
		current_normal:10,
	})
	const RTD = reactive({							//温度参数
		temperature:0,
		warnList:parameters.WARN_RTD,
		warn:0,		
		chipTemperature:0.0,
		resset1:100,
		resset2:400,
		resistance:0.0,			
		DACset1:100,
		DACset2:9000,
		DACReal1:null,
		DACReal2:null,
		sensor:0,
		sensorList:parameters.SENSOR_RTD,
		analogRange:0,
		analogRangeList:parameters.ANALOGRANGE_RTD,
		sampleRate:0b1011,
		sampleRateList:parameters.SAMPLERATE_RTD,
		temperature_min:1,
		temperature_max:4,
		ADCGain:1,
		ADCOffset:0,
		DACGain_10V:1,
		DACOffset_10V:0,
		DACGain_5V:1,
		DACOffset_5V:0,
		DACGain_20mA:1,
		DACOffset_20mA:0,
		current_normal:10,
		rangeMin:parameters.RANGEMIN_RTD,
		rangeMax:parameters.RANGEMAX_RTD,		
	})
	const analog = reactive({						//模拟量采集参数
		rangeList:[
			{ value: 0, text: "工程值"},
			{ value: 1, text: "原始值"}
		],		
		range:0,
		modeList:[
					{ value: 0, text: "0~5V"},
					{ value: 1, text: "0~20mA"}
				],
		analogUnit:["V","mA"],
		outputRange:[
					{ value: 0, text: "输出为正"},
					{ value: 1, text: "输出可负"}
				],
		ad0:0,
		ad1:0,
		ad2:0,
		ad3:0,
		ad0_mode:0,
		ad1_mode:0,
		ad2_mode:0,
		ad3_mode:0,
		ad0_real1:0,
		ad0_real2:0,
		ad1_real1:0,
		ad1_real2:0,
		ad2_real1:0,
		ad2_real2:0,
		ad3_real1:0,
		ad3_real2:0,		
		ad0_k:1,
		ad0_b:0,
		ad1_k:1,
		ad1_b:0,
		ad2_k:1,
		ad2_b:0,
		ad3_k:1,
		ad3_b:0,
		ad0_real1_A:0,
		ad0_real2_A:0,
		ad1_real1_A:0,
		ad1_real2_A:0,
		ad2_real1_A:0,
		ad2_real2_A:0,
		ad3_real1_A:0,
		ad3_real2_A:0,
		ad0_k_A:1,
		ad0_b_A:0,
		ad1_k_A:1,
		ad1_b_A:0,
		ad2_k_A:1,
		ad2_b_A:0,
		ad3_k_A:1,
		ad3_b_A:0,
		ad0_out:0,
		ad1_out:0,
		ad2_out:0,
		ad3_out:0,
		check_all:0,		
		offFrequency_AD0:0,
		offFrequency_AD1:0,
		offFrequency_AD2:0,
		offFrequency_AD3:0,
	})
	const liquidCool = reactive({					//液冷参数
		runList:[
			{ value: 0, text: "停止"},
			{ value: 1, text: "启动"}
		],			
		debugList:[
			{ value: 0, text: "关闭"},
			{ value: 1, text: "打开"}
		],		
		runmode:0,
		State:0,
		warn:0,
		warnList:parameters.WARN_L,
		press1:null,
		press2:null,
		speed_pump:null,
		speed_fan1:null,
		speed_fan2:null,
		speed_fan3:null,
		flow:null,
		temp1:null,
		temp2:null,
		temp3:null,
		pwm_pump:null,
		pwm_fan:null,
		run:0,
		debug:0,
		pump_set_D:10,
		fan_set_D:10,
		pwm1_Freq:50,
		pwm2_Freq:50,
		press_Max:100,
		flow_min:0,
		temp_set1:10,
		pump_set1:10,
		fan_set1:10,
		temp_set2:20,
		pump_set2:20,
		fan_set2:20,
		temp_set3:30,
		pump_set3:30,
		fan_set3:30,
		temp_set4:40,
		pump_set4:40,
		fan_set4:40,
		temp_set5:50,
		pump_set5:50,
		fan_set5:50,
		temp_set6:60,
		pump_set6:60,
		fan_set6:60,
		temp_set7:70,
		pump_set7:70,
		fan_set7:70,
		temp_set8:80,
		pump_set8:80,
		fan_set8:80,
		temp_set9:90,
		pump_set9:90,
		fan_set9:90,
		temp_set10:100,
		pump_set10:100,
		fan_set10:100,
		temp_set_N:30,
		pump_set_N:20,
		fan_set_N:20,
	})
	const encoder = reactive({						//编码器参数
		signList:[
					{ value: 1, text: "正" },
					{ value: -1, text: "负" }
				],
		sign_O:1,
		sign_A:1,
		pulseSet_I:60,
		pulseSet_O:60,
		reduct_M:1,
		reduct_D:1,
		angularRange_E:1,
		speedRange:3000,
		speed_I:0,
		angular_I:0,
		angular_O:0,
		angular_E:0,		
	})
	const encoderFunc = {
		read:async()=>{
			let res = await bleService.write(0x03,0x09,0x04)
			encoderFunc.allState(res)
		},
		allState:(e) =>{
			let i = 3;
			encoder.speed_I = converter.ab2s16(e[i++],e[i++]);
			encoder.angular_I = (converter.ab2s16(e[i++],e[i++])*0.01).toFixed(2);
			encoder.angular_O = (converter.ab2s16(e[i++],e[i++])*0.01).toFixed(2);
			encoder.angular_E = (converter.ab2s16(e[i++],e[i++])*0.01).toFixed(2);
		},
		sensorRead:async()=>{
			let res = await bleService.write(0x03,0x00,0x08)
			encoderFunc.sensorCanshu(res)
		},
		sensorCanshu:(e)=>{							//encoder配置参数解析
			let i = 3;		
			encoder.pulseSet_I = e[i++]<<8 | e[i++];
			encoder.pulseSet_O = e[i++]<<8 | e[i++];
			encoder.sign_A = converter.ab2s16(e[i++],e[i++]);
			encoder.sign_O = converter.ab2s16(e[i++],e[i++]);
			encoder.reduct_M = e[i++]<<8 | e[i++];
			encoder.reduct_D = e[i++]<<8 | e[i++];
			encoder.angularRange_E = converter.ab2s16(e[i++],e[i++])*0.01;
			encoder.speedRange = converter.ab2s16(e[i++],e[i++]);
		},
		sensorWrite:async()=>{
			let sensorData = [Number(encoder.pulseSet_I),
							Number(encoder.pulseSet_O),
							Number(encoder.sign_A),
							Number(encoder.sign_O),
							Number(encoder.reduct_M),
							Number(encoder.reduct_D),
							Number(encoder.angularRange_E)*100,
							Number(encoder.speedRange)
							]		
			let sensorRes = await bleService.write(0x10,0x00,sensorData);			
			if(sensorRes.length){							
				uni.showToast({
					title: '写入成功'
				});
			}else{
				uni.showToast({
					title: '写入失败'
				});
			}		
		},
		save:async()=>{
			let saveRes = await bleService.write(0x06,0x08,0x01);			
			if(saveRes.length){							
				uni.showToast({
					title: '保存成功'
				});
			}else{
				uni.showToast({
					title: '保存失败'
				});
			}		
		}
	}
	const getSystemInfo = () => {
		const sysInfo = uni.getSystemInfoSync()
		global.screenHeight = sysInfo.screenHeight
		global.statusBarHeight = sysInfo.statusBarHeight
		global.windowHeight = sysInfo.windowHeight
	}
	onMounted(()=>{		
		//console.log(global.timestamp,'timestamp');
		bleService.onBLEConnectionStateChange();
		getSystemInfo();
		setInterval(()=>{			//定时校验
			global.check = 1;			
		},5000)
		setInterval(()=>{			//定时读取			
			if(blue.connected && global.tabIndex == 1 && global.board == "ZN-BINLC"){
				ZN_BINLCFunc.readState()
			}
		},2000)
	})
	const change = {		
		deviceID:(e)=>{
			console.log("deviceID:", e.detail.value);
			if(e.detail.value){
				serial.slaveId_last = serial.slave_id
				serial.slave_id = 0xff
			}else{
				serial.slave_id = serial.slaveId_last
			}
		},
		baudRate_BLE:(e)=>{
			if(serial.baudRate_BLE_last == e){
				return
			}	
			serial.baudRate_BLE_last = e;
			console.log("baudRate_BLE:", e)
			bleService.config_BLE();
		},
		checkout_BLE:(e)=>{
			if(serial.checkout_BLE_last == e){
				return
			}	
			serial.checkout_BLE_last = e;
			console.log("checkout_BLE:", e);
			bleService.config_BLE();
		},
		stopBit_BLE:(e)=>{
			if(serial.stopBit_BLE_last == e){
				return
			}	
			serial.stopBit_BLE_last = e;
			console.log("stopBit_BLE:", e);
			bleService.config_BLE();
		},
		analogRange:(e)=>{
			console.log(e.detail.value,'analogRange')
			global.current = e.detail.value
			if(global.current == 0){
				RTD.DACset1 = 100
				RTD.DACset2 = 9000
			}else if(global.current == 1){
				RTD.DACset1 = 100
				RTD.DACset2 = 4500
			}else if(global.current == 2){
				RTD.DACset1 = 5000
				RTD.DACset2 = 19000
			}
			console.log(global.current,'global.current')
		},
		ontabtap:(e)=>{
			console.log(e,'ontabtap')
			global.tabIndex = e	
		},
		swiper:(e)=>{
			console.log(e,'swiper')
			global.tabIndex = e.target.current;
			global.check = 1;
			if(blue.connected && global.tabIndex == 1 && global.board == "ZN-BINLC"){
				uni.onBLECharacteristicValueChange((characteristic) => {
					//console.log('触发监听(onBLECharacteristicValueChange)');
					console.log('手机接收的数据：',converter.ab2str(characteristic.value));
					blue.showData.push({name:'RX:',value:converter.ab2str(characteristic.value)});
					const firstMatch = converter.ab2str(characteristic.value).match(/\{[^{}]*\}/);
					//console.log(firstMatch?.[0],tool.isJSON(firstMatch?.[0]),'firstMatch')
					if(tool.isJSON(firstMatch?.[0])){
						ZN_BINLCFunc.paramObj(JSON.parse(firstMatch?.[0]))
					}							
					if(test.type.includes(8)){
						global.timestamp = testFunc.formatTime();
						test.RXLength = test.RXLength + characteristic.value.byteLength
						test.log.unshift({name:test.type.includes(4)?global.timestamp+' RX:':' RX:',value:test.type.includes(2)?converter.ab2hex(characteristic.value):converter.ab2str(characteristic.value)});
					}												
					if(blue.showData.length>8){									//显示区数据大于8条把前面数据删掉
						blue.showData.splice(0,1)
					}
				})
			}
		},
		sendCycle:(e)=>{
			console.log(e.detail.value,test.cycle,'sendCycle')
			if(test.cycle.includes(1)){
				console.log('循环发送')
				test.timer = setInterval(()=>{
					testFunc.writeData()
				},test.time)
			}else{
				clearInterval(test.timer)
			}
		},
		cycleTime:(e)=>{
			if(e<test.timeMin){
				test.time = test.timeMin;			
			}else{
				test.time = e;
			}
			console.log(test.time,'test.time')
		},
		reply1:(e)=>{
			if(e<serial.replyMin){
				serial.reply = serial.replyMin;			
			}else if(e>serial.replyMax){
				serial.reply = serial.replyMax;
			}else{
				serial.reply = e;
			}
			console.log(serial.reply,'serial.reply')
		},
		reply2:(e)=>{
			if(e<serial.replyMin){
				serial.reply_2 = serial.replyMin;			
			}else if(e>serial.replyMax){
				serial.reply_2 = serial.replyMax;
			}else{
				serial.reply_2 = e;
			}
			console.log(serial.reply_2,'serial.reply_2')
		},
		PWM:(e)=>{
			console.log(e,ZDBL.param_PWM,'PWM')
		}
	}	

//ZN-BINLC相关函数
	const ZN_BINLC = reactive({
		version:null,
		productKey:null,
		deviceName:null,
		deviceSecret:null,
		Sim:0,
		dis:null,
		ic:null,
		weight:null,
		msg:null,
		out:null,
		in:null,
		vol:null
	})
	const ZN_BINLCFunc = {		
		writeData:(str)=>{		
			if(!blue.connected){
				uni.showToast({	title:'请先连接蓝牙',	icon:'none'})
				return
			}			
			const buffer = converter.str2ab(str)			
			uni.writeBLECharacteristicValue({				//写
				deviceId: blue.deviceId,
				serviceId: blue.serviceId,
				characteristicId: blue.characteristicId,
				value: buffer,
				complete:(e)=>{
					blue.showData.push({name:'TX:',value:converter.ab2str(buffer)});					
					if(blue.showData.length>8){
						blue.showData.splice(0,1)
					}
					if(test.type.includes(8)){
						global.timestamp = testFunc.formatTime();
						test.log.unshift({name:test.type.includes(4)?global.timestamp+' TX:':' TX:',value:test.type.includes(1)?converter.ab2hex(buffer):converter.ab2str(buffer)});
					}						
					console.log('手机发送的数据',converter.ab2str(buffer));	
				},
				success: (res) => {
					console.log(res,'success')	
				},
				fail: (err) => {						
					console.log(err,'fail')						
				}
			})
		},
		writeStr:()=>{
			let obj = {
				"version":ZN_BINLC.version,
				"ProductKey":ZN_BINLC.productKey,
				"DeviceName":ZN_BINLC.deviceName,
				"DeviceSecret":ZN_BINLC.deviceSecret
				}
			let str = JSON.stringify(obj)
			ZN_BINLCFunc.writeData(str)
		},
		readStr:()=>{
			let obj = {
				"version":"?",
				"ProductKey":"?",
				"DeviceName":"?",
				"DeviceSecret":"?"
				}
			let str = JSON.stringify(obj)			
			ZN_BINLCFunc.writeData(str)			
		},
		paramObj:(e)=>{
			console.log(e,'paramObj')			
			if(Object.keys(e).includes('version')){
				ZN_BINLC.version = e.version;
			}
			if(Object.keys(e).includes('ProductKey')){
				ZN_BINLC.productKey = e.ProductKey;
			}
			if(Object.keys(e).includes('DeviceName')){
				ZN_BINLC.deviceName = e.DeviceName;
			}
			if(Object.keys(e).includes('DeviceSecret')){
				ZN_BINLC.deviceSecret = e.DeviceSecret;
			}
			if(Object.keys(e).includes('dis')){
				ZN_BINLC.dis = e.dis;
			}
			if(Object.keys(e).includes('ic')){
				ZN_BINLC.ic = e.ic;
			}
			if(Object.keys(e).includes('weight')){
				ZN_BINLC.weight = e.weight;
			}
			if(Object.keys(e).includes('msg')){
				ZN_BINLC.msg = e.msg;
			}
			if(Object.keys(e).includes('out')){
				ZN_BINLC.out = e.out;
			}
			if(Object.keys(e).includes('in')){
				ZN_BINLC.in = e.in;
			}
			if(Object.keys(e).includes('vol')){
				ZN_BINLC.vol = e.vol;
			}
		},
		wakeUp_btn:()=>{
			let obj = {				
				"Sim":0	
			}
			let str = JSON.stringify(obj)
			ZN_BINLCFunc.writeData(str)
		},
		wakeUp_tim:()=>{
			let obj = {
				"Sim":1
			}
			let str = JSON.stringify(obj)
			ZN_BINLCFunc.writeData(str)
		},		
		readState:()=>{
			let obj = {
				"dis":"?",
				"ic":"?",
				"weight":"?",
				"msg":"?",
				"out":"?",
				"in":"?",
				"vol":"?"
			}
			let str = JSON.stringify(obj)
			ZN_BINLCFunc.writeData(str)			
		},		
		inputVersion:(value)=>{
			if(value == null) return
			ZN_BINLC.version = String(value).replace(/[\r\n]/g, '');
		},
		inputProductKey:(value)=>{
			if(value == null) return
			ZN_BINLC.productKey = String(value).replace(/[\r\n]/g, '');
		},
		inputDeviceName:(value)=>{
			if(value == null) return
			ZN_BINLC.deviceName = String(value).replace(/[\r\n]/g, '');
		},
		inputDeviceSecret:(value)=>{
			if(value == null) return
			ZN_BINLC.deviceSecret = String(value).replace(/[\r\n]/g, '');
		}
	}
//ZDBL相关函数
	const ZDBL = reactive({
		firmware:null,
		boot:null,
		hardware:null,
		serialNum:null,
		coefficient_D:null,
		coefficient_V:null,
		coefficient_A:null,
		coefficient_W:null,
		coefficient_T:null,
		coefficient_S:null,
		coefficient_L:null,
		voltage_max:null,
		voltage_min:null,
		current_rate:null,
		current_max:null,
		temperature_max:null,
		temperature_min:null,
		analogIN_min:0,
		analogIN_max:5,
		analogIN_median:3,
		analogIN_dead:3,
		current_align:0,
		current_identify:0,
		sample_num:3200,
		result_identify:0,
		progress_identify:0,
		inverterMode:0,
		inverterMode_default:0,
		inverterModeList:[
			{ value: 0, text: "六步换相"},
			{ value: 1, text: "FOC"},
			{ value: 1, text: "直流电机"}
		],
		runMode:0,
		runMode_default:0,
		rumModeList:parameters.RUNMODE_ZDBL,		
		run:0,
		runList:[
			{ value: 0, text: "停止"},
			{ value: 1, text: "启动"}
		],		
		param_PWM:0,
		param_voltage:0,
		param_current:0,
		param_speed:0,
		param_position_A:0,
		param_position_R:0,
		param_load:0,
		param_regenrative_brake:0,
		param_accelerate_speed:0,
		param_accelerate_time:0,
		param_decelerate_time:0,
		warn_config:0,
		warn_configList:[],
		warn_control:0,
		warn_controlList:[],
		warn_IO:0,
		warn_IOList:[],
		warn_position:0,
		warn_positionList:[],
		warn_communicate:0,
		warn_communicateList:[],		
		warn:0,
		warnList:parameters.WARN_ZDBL,
		err_config:0,
		clear_config:0,
		err_configList:[],
		err_control:0,
		clear_control:0,
		err_controlList:[],
		err_IO:0,
		clear_IO:0,
		err_IOList:[],
		err_position:0,
		clear_position:0,
		err_positionList:[],
		err_communicate:0,
		clear_communicate:0,
		err_communicateList:[],		
		err:0,
		clear_err:0,
		errList:parameters.WARN_ZDBL,	
		
		state:null,
		temperature:null,
		voltage:null,
		current:null,
		power:null,
		speed:null,
		position:null,
		hall:0,
		pole:2,
		Lq:0,
		Ld:0,
		R:0,
		back_EMF:0,
		rotational_inertia:0,
		force_V:0,
		current_zero_A:0,
		current_zero_B:0,
		current_zero_C:0,
		cutoffFrequency_V:0,
		cutoffFrequency_A:0,
		cutoffFrequency_W:0,
		cutoffFrequency_S:0,
		cutoffFrequency_P:0,
		cutoffFrequency_T:0,		
		source_IN:0,
		sourceList_IN:parameters.SOURCE_IN,
		source_start:0,
		sourceList_start:parameters.SOURCE_START,
		source_DIR:0,
		sourceList_DIR:parameters.SOURCE_DIR,
		track:0,
		trackList:parameters.TRACK,
		track_cutoffFrequency:0,
		track_slope:0,
		track_time:0,
		track_bezier:0,
		track_v_max:0,
		track_a_max:0,
		voltageRate:0,
		currentRate:0,
		speedMax:0,
		voltageBrake:0,
		overloadRatio:0,
		overloadMaximum:0,
		angleLead:0,
		param_work:0,
		param_workList:parameters.CONFIG_ZDBL,
		config_Iq:[],
		Iq_P:1,
		Iq_I:0,
		config_Id:[],
		Id_P:1,
		Id_I:0,
		config_Speed:[],
		Speed_P:1,
		Speed_I:0,
		Speed_D:0,
		Speed_D_F:0,
		config_Position:[],
		Position_P:1,
		Position_I:0,
		Position_D:0,
		Position_D_F:0,
		config_PID:[],
		configList_PID:[
			{ value: 1,text: '自动' }
		],
		
		OTAfile:null,
		OTAfileSize:0,
		status:'idle',
		progress:0,
		error:null,
		encodeBinData:null,
		timer:null
	})
	const ZDBLFunc = {
		stateRead:async()=>{
			let res = await bleService.write(0x03,0x05DC,0x07)
			ZDBLFunc.allState(res)
		},
		allState:(e)=>{
			let i = 3;
			ZDBL.state = ZDBLFunc.state(e[i++]<<8|e[i++]);
			ZDBL.temperature = converter.ab2s16(e[i++],e[i++])*0.1;
			ZDBL.voltage = converter.ab2s16(e[i++],e[i++])*0.1;
			ZDBL.current = converter.ab2s16(e[i++],e[i++])*0.1;
			ZDBL.power = converter.ab2s16(e[i++],e[i++])*0.1;
			ZDBL.speed = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
			ZDBL.position = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
		},
		state:(e)=>{
			if(e == 0){
				return 'fault'
			}else if(e == 1){
				return 'idle'
			}else if(e == 2){
				return '参数辨识'
			}else if(e == 3){
				return '启动'
			}else if(e == 4){
				return '准备运行'
			}else if(e == 5){
				return '运行'
			}
		},
		clearWarn:async()=>{
			let res = await bleService.write(0x10,0x05D5,[0,0,0,0,0,0,0])
			if(res.length){
				uni.showToast({
					title: '清除成功'
				});
			}else{
				uni.showToast({
					title: '清除失败'
				});
			}
		},
		basicRead:async()=>{
			let res = await bleService.write(0x03,0x01,0x1F)
			ZDBLFunc.basicInfo(res)
		},
		basicInfo:(e)=>{
			let i = 3;
			ZDBL.firmware = e[i++]<<8|e[i++];
			ZDBL.boot = e[i++]<<8|e[i++];
			ZDBL.hardware = e[i++]<<8|e[i++];
			ZDBL.serialNum = converter.ab2s64(e[i++],e[i++],e[i++],e[i++],e[i++],e[i++],e[i++],e[i++]);
			ZDBL.coefficient_D = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
			ZDBL.coefficient_V = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
			ZDBL.coefficient_A = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
			ZDBL.coefficient_W = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
			ZDBL.coefficient_T = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
			ZDBL.coefficient_S = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
			ZDBL.coefficient_L = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
			ZDBL.voltage_max = converter.ab2s16(e[i++],e[i++])*0.1;
			ZDBL.voltage_min = converter.ab2s16(e[i++],e[i++])*0.1;
			ZDBL.current_rate = converter.ab2s16(e[i++],e[i++])*0.1;
			ZDBL.current_max = converter.ab2s16(e[i++],e[i++])*0.1;
			ZDBL.temperature_max = converter.ab2s16(e[i++],e[i++])*0.1;
			ZDBL.temperature_min = converter.ab2s16(e[i++],e[i++])*0.1;
		}
	}
	const otaUpgrader = {							//ota升级
		prepareFirmware:()=>{						//导入文件
			//1、选择文件
			const fileManager = wx.getFileSystemManager();
			wx.chooseMessageFile({
			  count: 1, // 仅选1个文件
			  type: 'file', // 文件类型
			  extension: ['.bin'], // 限制为.bin文件[1](@ref)
			  success: (res) => {
				console.log(res,'chooseMessageFile')
			    const tempFilePath = res.tempFiles[0].path; // 获取临时路径			
				const destPath = `${wx.env.USER_DATA_PATH}/firmware_${Date.now()}.bin`; // 必须使用指定目录[3](@ref)			
				//2、复制文件到指定路径
				fileManager.copyFile({
				  srcPath:tempFilePath,
				  destPath: destPath,
				  success: (copyRes) => {
					  console.log(copyRes,'copyFile')
					  //3、读取.bin文件
					fileManager.readFile({
					  filePath:destPath,
					  encoding: 'base64', // 关键：指定二进制格式[3](@ref)
					  success: (res) => {			  
						  console.log(res.data.length,'readFile')
						  //console.log(res,'readFile')
					    const arrayBuffer = uni.base64ToArrayBuffer(res.data);
						console.log(arrayBuffer,'arrayBuffer')
						const unit8Array = new Uint8Array(arrayBuffer);					
						console.log(unit8Array,'unit8Array')
						ZDBL.OTAfileSize = res.data.length
						//4、加密文件
						ZDBL.encodeBinData = fileEncryptor.encodeBin(unit8Array);
						console.log(ZDBL.encodeBinData,'ZDBL.encodeBinData')
					  },
					  fail: (err) => console.log('读取失败: ' + err.errMsg)
					})
				  },
				  fail: (err) => console.log('复制失败: ' + err.errMsg)
				});
			  },
			  fail: (err) => {
			    console.log(err,'chooseMessageFile')
			  }
			});		
		},
		upgrade:async()=>{
			//1、检测设备是否在线
			await otaUpgrader.checkDevice()		
			//2、获取boot默认jump地址
			let res = await otaUpgrader.getAddr()
			const {funcCode,payload,rawData} = otaUpgrader.parseFrame(res)
			const startAddr = (payload[0] << 24) | (payload[1] << 16) | (payload[2] << 8) | payload[3]
			const jumpAddr = (payload[0] << 24) | (payload[1] << 16) | (payload[2] << 8) | payload[3]
			const endAddr = startAddr + ZDBL.OTAfileSize - 1
			console.log(payload,startAddr,endAddr,'parseFrame')
			//3、擦除flash
			await otaUpgrader.eraseFlash(startAddr, endAddr)
			//4、写入bin文件
			let res2 = await otaUpgrader.writeFirmware(startAddr)
			console.log(res2,'writeFirmware')
			//5、跳转至主程序
			let res3 = await otaUpgrader.jumpToApp(jumpAddr)
			console.log(res3,'jumpToApp')
		},
		checkDevice:async()=>{								//检查设备是否在线
			ZDBL.status = 'connecting'
			return new Promise((resolve, reject) =>{
				const random = new Uint8Array([0xF0, 0x44, 0xBF, 0x30]);
				const frame = otaUpgrader.buildFrame(0x01, random);
				otaUpgrader.reSet()
				ZDBL.timer = setInterval(async()=>{
					const res = await otaUpgrader.sendData(frame)
					console.log(res)
					if(res.byteLength){
						console.log("接收到数据",res)
						clearInterval(ZDBL.timer)
						resolve(res)
					}
				},200)			
			})
		},
		stopCheck:()=>{										//停止检查设备是否在线
			clearInterval(ZDBL.timer)
		},
		getAddr:()=>{										//获取boot默认jump地址
			ZDBL.status = 'getAddr'
			return new Promise(async(resolve, reject) =>{
				//const payload = null;
				const frame = otaUpgrader.buildFrame(0x04);
				const res = await otaUpgrader.sendData(frame)
				console.log(res)			
				resolve(res)
			})
		},
		eraseFlash:(startAddr, endAddr)=>{					//擦除flash
			ZDBL.status = 'eraseFlash'
			return new Promise(async(resolve, reject) =>{
				const payload = new Uint8Array(8);
				// 大端模式写入地址
				payload[0] = (startAddr >> 24) & 0xFF;
				payload[1] = (startAddr >> 16) & 0xFF;
				payload[2] = (startAddr >> 8) & 0xFF;
				payload[3] = startAddr & 0xFF;
				payload[4] = (endAddr >> 24) & 0xFF;
				payload[5] = (endAddr >> 16) & 0xFF;
				payload[6] = (endAddr >> 8) & 0xFF;
				payload[7] = endAddr & 0xFF;
				console.log(payload,'eraseFlash')
				const frame = otaUpgrader.buildFrame(0x05, payload);
				const res = await otaUpgrader.sendData(frame)			  
				resolve(res)
			})
		},
		writeFirmware(startAddr){							//写入更新文件，分包处理
			ZDBL.status = 'writing'
			ZDBL.progress = 0
			// 计算需要多少包(每包最大数据量=64-1-1-1-2-4-1=54字节)
			return new Promise(async(resolve, reject)=>{
				const chunkSize = 54;
				const totalChunks = Math.ceil(ZDBL.encodeBinData.length / chunkSize);
				for(let i = 0; i < totalChunks ; i++){
					const chunkStart = i * chunkSize;
					const chunkEnd = Math.min(chunkStart + chunkSize, ZDBL.encodeBinData.length);
					const chunk = ZDBL.encodeBinData.slice(chunkStart, chunkEnd);				
					// 构建payload: 4字节地址 + 1字节长度 + 数据
					const currentAddr = startAddr + chunkStart;
					const payload = new Uint8Array(5 + chunk.length);				
					// 大端模式写入地址
					payload[0] = (currentAddr >> 24) & 0xFF;
					payload[1] = (currentAddr >> 16) & 0xFF;
					payload[2] = (currentAddr >> 8) & 0xFF;
					payload[3] = currentAddr & 0xFF;
					payload[4] = chunk.length;
					// 复制数据
					for (let j = 0; j < chunk.length; j++) {
					  payload[5 + j] = chunk[j];
					}
					const frame = otaUpgrader.buildFrame(0x06, payload);
					const res = await otaUpgrader.sendData(frame)					
					ZDBL.progress = Math.round(((i+1)/totalChunks)*100)					
				}
				resolve(ZDBL.progress)
			})			
		},
		jumpToApp:(jumpAddr)=>{									//跳转至主程序
			ZDBL.status = 'jumpToApp'		
			return new Promise(async(resolve, reject)=>{
				const payload = new Uint8Array(4);
				// 大端模式写入地址
				payload[0] = (jumpAddr >> 24) & 0xFF;
				payload[1] = (jumpAddr >> 16) & 0xFF;
				payload[2] = (jumpAddr >> 8) & 0xFF;
				payload[3] = jumpAddr & 0xFF;
				const frame = otaUpgrader.buildFrame(0x02, payload);
				console.log(frame,'frame jumpToApp')
				const res = await otaUpgrader.sendData(frame)			  
				resolve(res)
			})
		},
		buildFrame:(funcCode, payload = new Uint8Array(0))=>{
		  const length = 1 + payload.length; // funcCode + payload
		  const frame = new Uint8Array(1 + 1 + length + 2); // head + length + (func + payload) + checksum	  
		  let offset = 0;
		  frame[offset++] = 0xAA; // head
		  frame[offset++] = length+4; // length	  
		  frame[offset++] = funcCode;	// func code	  
		  for (let i = 0; i < payload.length; i++) {	// payload
		    frame[offset++] = payload[i];
		  }	  
		  let sum = 0;			
		  for (let i = 0; i < offset; i++) {
		    sum += frame[i];
		  }	  
		  frame[offset++] = (sum >> 8) & 0xFF;
		  frame[offset++] = sum & 0xFF;
		  return frame;
		},
		parseFrame:(data)=>{
		  const head = data[0];	  
		  if (head !== 0xAA) return null;	  
		  const length = data[1];	  
		  if (data.length < length) return null; // 检查长度是否足够  
		  // 校验checksum
		  let sum = 0;
		  for (let i = 0; i < length-2; i++) {
		    sum += data[i];
		  }	  
		  const checksum = (data[length-2] << 8) | data[length-1];	  
		  if (sum !== checksum) return null;	  
		  return {
		    funcCode: data[2],
		    payload: data.slice(3, length-2),
		    rawData: data
		  };
		},
		sendData:(data)=>{
			return new Promise((resolve, reject) =>{
				if(!blue.connected){
					uni.showToast({	title:'请先连接蓝牙',	icon:'none'})
					return
				}
				const buffer = data.buffer
				//console.log(buffer,'buffer')			
				uni.writeBLECharacteristicValue({				//写
					deviceId: blue.deviceId,
					serviceId: blue.serviceId,
					characteristicId: blue.characteristicId,
					value: buffer,
					complete:(e)=>{						
						if(ZDBL.status == 'jumpToApp'){
							console.log('手机发送的数据jumpToApp',converter.ab2hex(buffer));
						}
						blue.showData.push({name:'TX:',value:converter.ab2hex(buffer)});
					},
					success: (res) => {				
						// 操作之前先监听，保证第一时间获取数据（value就是特征值当前最新的值）				
						//监听低功耗蓝牙设备的特征值变化事件。必须先启用 notifyBLECharacteristicValueChange 接口才能接收到设备推送的 notification
						uni.onBLECharacteristicValueChange((characteristic) => {							
							if(ZDBL.status == 'jumpToApp'){
								console.log('手机接收的数据jumpToApp',converter.ab2hex(characteristic.value));
							}
							blue.showData.push({name:'RX:',value:converter.ab2hex(blue.receiveData)});
							blue.receiveData = new Uint8Array(characteristic.value)
							resolve(blue.receiveData)						
						})					
					},
					fail: (err) => {				
						console.log(err,'fail')
						reject(err)									
					}
				})
			})
		},
		reSet:async()=>{
			await bleService.write(0x06,61,0xAA55)
			let res = await bleService.write(0x06,61,0x55AA)
			console.log(res,'reSet')
		},
		getID:async()=>{
			let res = await bleService.write(0x03,0x00,0x01);
			console.log(res,'getID')
		}
		
	}
//垃圾分类相关函数
	const recycle = reactive({						//垃圾分类
		sensorError:[],
		sensorErrorList:parameters.WARN_WTA,
		currentWeight:null,
		sensorPVoltage:null,
		sensorNVoltage:null,
		inputValue:null,
		inputValue2:null,
		
		config:[],
		configNL:[],
		configNH:[],
		configList_GS24:parameters.CONFIG_GS24,
		configList_GS24NL:parameters.CONFIG_GS24NL,
		configList_GS24NH:parameters.CONFIG_GS24NH,
		configList_DC2405:parameters.CONFIG_DC2405,		
		range:0,
		rangeList:[
					{ value: 0, text: "0~4095" },
					{ value: 1, text: "-20~80℃" },
					{ value: 2, text: "-40~80℃" }
				],
		board:0,
		boardList:[
					{ value: 0, text: "分控板" },
					{ value: 1, text: "DC2405" }
				],
		weight:null,
		pitchWeight:null,
		temperature:null,
		humidity:null,
		di3count:null,
		current:null,
		choose:false,
		photoelectric:false,		
		full:false,
		smoke:false,
		lock:false,
		antiPinch:false,
		realTimeFull:false,
		time_input:false,
		limit_P:false,
		limit_R:false,
		putState:null,
		pushrod:null,
		communication:false,
		interaction:null,
		weightSet:null,
		function:null,
		functionNL:null,
		functionNH:null,
		warnTime:null,
		pushTime:null,
		holdTime:null,
		backTime:null,
		current_max:null,
		modbusId:null,
		gain:null,
		offset:null,
		current_normal:null,
		current_open:null,
		current_close:null,		
		distanceRange:null,
		distanceLimit:null,
		distanceSlow:null,		
		countFilter:null,
		volume:null,
		smallCurrent:null,
		
	})
	const recycleFunc = {
		stateRead:async()=>{						//状态读取
			let res = await bleService.write(0x03,0x00,0x0D);
			recycleFunc.state_All(res)
		},
		state_All:(e)=>{							//状态解析
			let i = 3;
			recycle.weight = (e[i++]<<8 | e[i++])<<16 | e[i++]<<8 | e[i++];		
			recycleFunc.state_Sensor(e[i++]<<8 | e[i++]);		
			recycle.temperature = converter.ab2s16(e[i++],e[i++]);
			recycle.humidity = converter.ab2s16(e[i++],e[i++]);
			recycleFunc.state_Pusher(e[i++]<<8 | e[i++]);		
			recycleFunc.state_Pitch(e[i++]<<8 | e[i++]);		
			recycleFunc.state_Choose(e[i++]<<8 | e[i++]);		
			recycle.current = e[i++]<<8 | e[i++];		
			recycle.pitchWeight = (e[i++]<<8 | e[i++])<<16 | e[i++]<<8 | e[i++];		
			recycle.di3count = e[i++]<<8 | e[i++];		
			recycleFunc.state_Communicat(e[i++]<<8 | e[i++]);
		},
		state_Sensor:(e)=>{							//传感器状态解析
			recycle.photoelectric = e & 0x01
			recycle.full = e & 0x02
			recycle.smoke = e & 0x04
			recycle.lock = e & 0x08
			recycle.antiPinch = e & 0x10
			recycle.time_input = e & 0x20
			recycle.realTimeFull = e & 0x40
			recycle.limit_P = e & 0x100
			recycle.limit_R = e & 0x200	
		},
		state_Pusher:(e)=>{							//推杆状态解析
			if(e == 0){
				recycle.pushrod = '停止'
			}else if(e == 1){
				recycle.pushrod = '推出'
			}else if(e == 2){
				recycle.pushrod = '保持'
			}else if(e == 3){
				recycle.pushrod = '缩回'
			}else if(e == 4){
				recycle.pushrod = '等待'
			}else if(e == 5){
				recycle.pushrod = '刹车'
			}else if(e == 6){
				recycle.pushrod = '其它'
			}
		},
		state_Choose:(e)=>{							//选中状态
			if(e == 0){
				recycle.choose = false
			}else{
				recycle.choose = true
			}
		},
		state_Pitch:(e)=>{							//投放状态
			if(e == 0){
				recycle.putState = '投放完毕'
			}else{
				recycle.putState = '投放中'
			}
		},
		state_Communicat:(e)=>{						//通信状态
			if(e == 0){
				recycle.communication = '通信正常'
			}else{
				recycle.communication = '未连接'
			}
		},
		state2Read:async()=>{						//状态读取
			let res = await bleService.write(0x04,0x20,0x0A);
			recycleFunc.state2_All(res)
		},
		state2_All:(e)=>{
			let i = 3;
			recycle.weight = (e[i++]<<8 | e[i++])<<16 | e[i++]<<8 | e[i++];
			recycle.sensorError = recycleFunc.state_Func(e[i++]<<8 | e[i++]);
			recycle.currentWeight = (e[i++]<<8 | e[i++])*0.1;
			recycle.sensorPVoltage = e[i++]<<8 | e[i++];
			recycle.sensorNVoltage = e[i++]<<8 | e[i++];
			recycle.inputValue = e[i++]<<8 | e[i++];
			recycle.inputValue2 = e[i++]<<8 | e[i++];
			recycle.temperature = converter.ab2s16(e[i++],e[i++]);
			recycle.humidity = converter.ab2s16(e[i++],e[i++]);			
		},
		interactRead:async() => {					//感应读取
			let res =  await bleService.write(0x03,0x18,0x01);
			recycleFunc.state_interact(res[3]<<8 | res[4]);
			
		},
		state_interact:(e)=>{						//感应状态
			if(e == 0){
				recycle.interaction = '感应关闭'
			}else if(e == 1){
				recycle.interaction = '感应打开'
			}else if(e == 2){
				recycle.interaction = '感应打开'
			}
		},
		clear:async()=>{							//清零
			await bleService.write(0x06,0x0d,0x02);
			await bleService.write(0x06,0x15,0x01);
		},
		check:async()=>{							//校准
			await bleService.write(0x06,0x0d,0x02);
			await bleService.write(0x06,0x17,recycle.weightSet);
			await bleService.write(0x06,0x15,0x02);
		},
		configRead:async()=>{						//配置读取
			if(global.board == '垃圾分类'){
				let res = await bleService.write(0x03,0x19,0x0b)
				recycleFunc.param_All(res);
			}else{
				let res = await bleService.write(0x03,0x19,0x16)
				recycleFunc.param_All_N(res);				
			}
		},
		configWrite:async()=>{						//配置写入
			if(global.board == '垃圾分类'){
				let data = [Number(recycle.function),
							Number(recycle.warnTime),
							Number(recycle.pushTime),
							Number(recycle.holdTime),
							Number(recycle.backTime),
							Number(recycle.current_max),
							Number(recycle.modbusId),
							...converter.float2ab(recycle.gain),
							...converter.float2ab(recycle.offset)						
							]
				let res = await bleService.write(0x10,0x19,data);
				if(res.length){
					uni.showToast({
						title: '写入成功'
					});
				}else{
					uni.showToast({
						title: '写入失败'
					});
				}
			}else{
				let data = [Number(recycle.functionNL),
							Number(recycle.functionNH),
							Number(recycle.pushTime),
							Number(recycle.holdTime),
							Number(recycle.backTime),
							Number(recycle.current_open),
							Number(recycle.current_close),
							...converter.float2ab(recycle.gain),
							...converter.float2ab(recycle.offset),
							null,
							null,							
							Number((recycle.distanceRange>>16) & 0xffff),
							Number(recycle.distanceRange & 0xffff),
							Number(recycle.distanceLimit),
							Number(recycle.smallCurrent),
							Number(recycle.distanceSlow),
							Number(recycle.countFilter),
							Number(recycle.volume),
							Number(recycle.warnTime),
							Number(recycle.current_normal),
							Number(recycle.modbusId),
							]						
				let res = await bleService.write(0x10,0x19,data);				
				if(res.length){
					uni.showToast({
						title: '写入成功'
					});
				}else{
					uni.showToast({
						title: '写入失败'
					});
				}
			}
		},
		save:async()=>{								//配置保存
			if(global.board == '垃圾分类'){
				let res = await bleService.write(0x06,0x24,0x01);			
				if(res.length){
					uni.showToast({
						title:'保存成功'
					})
				}else{
					uni.showToast({
						title:'保存失败'
					})
				}
			}else{
				await bleService.write(0x06,0x24,0x01);
				let res = await bleService.write(0x06,0x9F,0x01);
				if(res.length){
					uni.showToast({
						title:'保存成功'
					})
				}else{
					uni.showToast({
						title:'保存失败'
					})
				}
			}
		},
		reset:async()=>{							//重启
			let res = await bleService.write(0x06,0x24,0xaa00);
			if(res.length){
				uni.showToast({
					title:'重启成功'
				})
			}else{
				uni.showToast({
					title:'重启失败'
				})
			}
		},
		param_All:(e)=>{							//配置参数解析
			let i = 3;
			recycle.function = e[i++]<<8 | e[i++];
			recycleFunc.state_Func(recycle.function);
			recycle.warnTime = e[i++]<<8 | e[i++];
			recycle.pushTime = e[i++]<<8 | e[i++];
			recycle.holdTime = e[i++]<<8 | e[i++];
			recycle.backTime = e[i++]<<8 | e[i++];
			recycle.current_max = e[i++]<<8 | e[i++];
			recycle.modbusId = e[i++]<<8 | e[i++];
			recycle.gain = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			recycle.offset = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		},
		param_All_N:(e)=>{							//配置参数解析
			let i = 3;
			recycle.functionNL = e[i++]<<8 | e[i++];
			recycle.functionNH = e[i++]<<8 | e[i++];
			recycle.configNL = recycleFunc.state_Func(recycle.functionNL);
			recycle.configNH = recycleFunc.state_Func(recycle.functionNH);
			recycle.pushTime = e[i++]<<8 | e[i++];
			recycle.holdTime = e[i++]<<8 | e[i++];
			recycle.backTime = e[i++]<<8 | e[i++];
			recycle.current_open = e[i++]<<8 | e[i++];
			recycle.current_close = e[i++]<<8 | e[i++];
			recycle.gain = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			recycle.offset = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			e[i++];
			e[i++];
			e[i++];
			e[i++];			
			recycle.distanceRange = (e[i++]<<8 | e[i++])<<16 | (e[i++]<<8 | e[i++]);
			recycle.distanceLimit = e[i++]<<8 | e[i++];
			recycle.smallCurrent = e[i++]<<8 | e[i++];			
			recycle.distanceSlow = e[i++]<<8 | e[i++];
			recycle.countFilter = e[i++]<<8 | e[i++];
			recycle.volume = e[i++]<<8 | e[i++];
			recycle.warnTime = e[i++]<<8 | e[i++];
			recycle.current_normal = e[i++]<<8 | e[i++];
			recycle.modbusId = e[i++]<<8 | e[i++];
		},
		state_Func:(e)=>{							//功能参数解析
			let temp = [];
			for(let i = 0;i<16;i++){
				if(e&(1<<i)){
					temp.push(i)
				}
			}
			return temp;
		},
		change_Func:(e)=>{							//功能参数
			let temp = 0;
			for(let i=0;i<e.detail.value.length;i++){
				temp |= (1<<e.detail.value[i]);
			}		
			recycle.function = temp;			
		},
		change_FuncNL:(e)=>{							//功能参数
			let temp = 0;
			for(let i=0;i<e.detail.value.length;i++){
				temp |= (1<<e.detail.value[i]);
			}		
			recycle.functionNL = temp;			
		},
		change_FuncNH:(e)=>{							//功能参数
			let temp = 0;
			for(let i=0;i<e.detail.value.length;i++){
				temp |= (1<<e.detail.value[i]);
			}		
			recycle.functionNH = temp;			
		}
	}
	
//系统校验相关函数
	async function check(e){
		if (global.check) {
			let res = await jiaoYan();
			global.check = 0;
		}
		global.searchBaud = 0;
		switch(e){			
			case 'searchBoard':searchBoard();				//检索控制板类型
			break;
			case 'autoRead':autoRead();						//自动读取
			break;			
			case 'save':save();								//保存
			break;
			//串口相关函数
			case 'serialRead':serialRead();					//串口1读取
			break;
			case 'serialWrite':serialWrite();				//串口1写入
			break;
			case 'serialRead2':serialRead2();				//串口2读取
			break;
			case 'serialWrite2':serialWrite2();				//串口2写入
			break;
			//垃圾分类
			case 'recycleFunc.stateRead':recycleFunc.stateRead();						//状态信息读取
			break;
			case 'recycleFunc.state2Read':recycleFunc.state2Read();						//状态信息读取
			break;
			case 'Recycle_open':bleService.write(0x06,0x0E,0x01);						//状态信息读取
			break;
			case 'Recycle_openUp':bleService.write(0x06,0x0E,0x08);						//状态信息读取
			break;
			case 'Recycle_openDown':bleService.write(0x06,0x0E,0xF8);						//状态信息读取
			break;
			case 'Recycle_stop':bleService.write(0x06,0x0E,0xf0);						//状态信息读取
			break;
			case 'Recycle_close':bleService.write(0x06,0x0E,0xff);						//状态信息读取
			break;
			case 'Recycle_openDoor':bleService.write(0x06,0x0F,0x01);						//状态信息读取
			break;
			case 'recycleFunc.interactRead':recycleFunc.interactRead();						//状态信息读取
			break;
			case 'Recycle_openSensor':bleService.write(0x06,0x18,0x01);						//状态信息读取
			break;
			case 'Recycle_closeSensor':bleService.write(0x06,0x18,0x00);						//状态信息读取
			break;
			case 'Recycle_unlock':bleService.write(0x06,0x11,0x01);						//状态信息读取
			break;
			case 'Recycle_lock':bleService.write(0x06,0x11,0x00);						//状态信息读取
			break;
			case 'Recycle_lightOn':bleService.write(0x06,0x12,0x01);						//状态信息读取
			break;
			case 'Recycle_lightOff':bleService.write(0x06,0x12,0x00);						//状态信息读取
			break;
			case 'recycleFunc.clear':recycleFunc.clear();						//状态信息读取
			break;
			case 'recycleFunc.check':recycleFunc.check();						//状态信息读取
			break;
			case 'recycleFunc.configRead':recycleFunc.configRead();						//状态信息读取
			break;
			case 'recycleFunc.configWrite':recycleFunc.configWrite();						//状态信息读取
			break;
			case 'recycleFunc.save':recycleFunc.save();								//保存
			break;
			case 'recycleFunc.reset':recycleFunc.reset();								//保存
			break;
			//扭矩转速变送器
			case 'TSAFunc.open_DAC':TSAFunc.open_DAC();				//打开DAC
			break;
			case 'TSAFunc.close_DAC':TSAFunc.close_DAC();				//关闭DAC
			break;
			case 'TSAFunc.write_DAC':TSAFunc.write_DAC();				//写入DAC
			break;
			case 'TSAFunc.read_DAC':TSAFunc.read_DAC();				//读取DAC
			break;
			case 'TSAFunc.stateRead':TSAFunc.stateRead();						//状态信息读取
			break;						
			case 'TSAFunc.sample_T1':TSAFunc.sample_T1();	//转矩采样1		
			break;
			case 'TSAFunc.sample_T2':TSAFunc.sample_T2();	//转矩采样2
			break;
			case 'TSAFunc.check_T':TSAFunc.check_T();		//转矩校准
			break;
			case 'TSAFunc.sample_S1':TSAFunc.sample_S1();		//速度采样1
			break;
			case 'TSAFunc.sample_S2':TSAFunc.sample_S2();		//速度采样2
			break;
			case 'TSAFunc.check_S':TSAFunc.check_S();			//速度校准
			break;
			case 'TSAFunc.check_F':TSAFunc.check_F();	//频率校准
			break;
			case 'TSAFunc.check_close':TSAFunc.check_close();			//关闭校准
			break;
			case 'TSAFunc.checkRead':TSAFunc.checkRead();			//校准参数读取
			break;
			case 'TSAFunc.checkWrite':TSAFunc.checkWrite();			//校准参数写入
			break;
			case 'TSAFunc.sensorRead':TSAFunc.sensorRead();			//传感器参数读取
			break;
			case 'TSAFunc.sensorWrite':TSAFunc.sensorWrite();		//传感器参数写入
			break;
			case 'TSAFunc.configRead':TSAFunc.configRead();			//配置信息全读
			break;
			case 'TSAFunc.configWrite':TSAFunc.configWrite();					//配置信息全写
			break;
			//压力变送器相关函数
			case 'WTA_read':WTA_read();						//状态信息读取
			break;
			case 'WTA_clear':WTA_clear();					//清零
			break;
			case 'WTA_check':WTA_check();					//校准
			break;
			case 'WTA_DACSample1':WTA_DACSample1();			//DAC采样1
			break;
			case 'WTA_DACSample2':WTA_DACSample2();			//DAC采样2
			break;
			case 'WTA_DACCheck':WTA_DACCheck();				//DAC校准
			break;
			case 'WTA_checkRead':WTA_checkRead();			//校准参数读取
			break;
			case 'WTA_checkWrite':WTA_checkWrite();			//校准参数写入
			break;
			case 'WTA_sensorRead':WTA_sensorRead();			//传感器参数读取
			break;
			case 'WTA_sensorWrite':WTA_sensorWrite();		//传感器参数写入
			break;
			case 'WTA_weightRead':WTA_weightRead();			//重量信息读取
			break;
			case 'WTA_weightWrite':WTA_weightWrite();		//重量信息写入
			break;
			case 'WTA_readConfig':WTA_readConfig();			//配置信息全读
			break;
			case 'WTA_write':WTA_write();					//配置信息全写
			break;
			case 'WTA01_read':WTA01_read();					//状态读取
			break;
			case 'WTA01_clear':WTA01_clear();				//清零
			break;
			case 'WTA01_check':WTA01_check();				//校准
			break;			
			case 'WTA01_checkRead':WTA01_checkRead();		//校准参数读取
			break;
			case 'WTA01_checkWrite':WTA01_checkWrite();		//校准参数写入
			break;
			case 'WTA01_sensorRead':WTA01_sensorRead();		//传感器配置读取
			break;
			case 'WTA01_sensorWrite':WTA01_sensorWrite();	//传感器配置写入
			break;
			case 'WTA01_weightRead':WTA01_weightRead();		//重量配置读取
			break;
			case 'WTA01_weightWrite':WTA01_weightWrite();	//重量配置写入
			break;
			case 'WTA01_readConfig':WTA01_readConfig();		//配置信息全读
			break;
			case 'WTA01_write':WTA01_write();				//配置信息全写
			break;
			case 'WTA01_save':WTA01_save();					//保存
			break;
			case 'Reset':Reset();				//重启
			break;
			case 'WTA01_serialRead':WTA01_serialRead();		//串口配置读取
			break;
			case 'WTA01_serialWrite':WTA01_serialWrite();	//串口配置写入
			break;
			//温度变送器相关函数
			case 'RTD_read':RTD_read();						//状态信息读取
			break;
			case 'RTD_ResSample1':RTD_ResSample1();			//阻值采样1
			break;
			case 'RTD_ResSample2':RTD_ResSample2();			//阻值采样2
			break;
			case 'RTD_DACSample1':RTD_DACSample1();			//DAC采样1
			break;
			case 'RTD_DACSample2':RTD_DACSample2();			//DAC采样2
			break;
			case 'RTD_DACCheck':RTD_DACCheck();				//DAC校准
			break;
			case 'RTD_checkRead':RTD_checkRead();			//校准参数读取
			break;
			case 'RTD_checkWrite':RTD_checkWrite();			//校准参数写入
			break;			
			case 'RTD_sensorRead':RTD_sensorRead();			//传感器参数读取
			break;
			case 'RTD_sensorWrite':RTD_sensorWrite();		//传感器参数写入
			break;
			case 'RTD_readConfig':RTD_readConfig();			//配置信息全读
			break;
			case 'RTD_write':RTD_write();					//配置信息全写
			break;
			//模拟量相关函数
			case 'A_read':A_read();						//状态信息读取
			break;
			case 'A_modeRead':A_modeRead();
			break;
			case 'A_modeWrite':A_modeWrite();
			break;
			case 'ad0_sample1':ad0_sample1();
			break;
			case 'ad0_sample2':ad0_sample2();
			break;
			case 'ad0_read':ad0_read();
			break;
			case 'ad0_write':ad0_write();
			break;
			case 'ad1_sample1':ad1_sample1();
			break;
			case 'ad1_sample2':ad1_sample2();
			break;
			case 'ad1_read':ad1_read();
			break;
			case 'ad1_write':ad1_write();
			break;
			case 'ad2_sample1':ad2_sample1();
			break;
			case 'ad2_sample2':ad2_sample2();
			break;
			case 'ad2_read':ad2_read();
			break;
			case 'ad2_write':ad2_write();
			break;
			case 'ad3_sample1':ad3_sample1();
			break;
			case 'ad3_sample2':ad3_sample2();
			break;
			case 'ad3_read':ad3_read();
			break;
			case 'ad3_write':ad3_write();
			break;
			case 'A_frequencyRead':A_frequencyRead();
			break;
			case 'A_frequencyWrite':A_frequencyWrite();
			break;
			case 'A_outputRead':A_outputRead();
			break;
			case 'A_outputWrite':A_outputWrite();
			break;
			case 'A_serialRead':A_serialRead();
			break;
			case 'A_serialWrite':A_serialWrite();
			break;
			case 'A_serialRead2':A_serialRead2();
			break;
			case 'A_serialWrite2':A_serialWrite2();
			break;
		}
	}
	const jiaoYan = function(){						//校验
		return new Promise(async (resolve,reject)=>{			
			let random = Math.floor(Math.random()*65536);
			await bleService.write(0x06,0x16,random);			
			let res = await bleService.write(0x03,0x16,0x01);
			let resData = res[3]<<8 | res[4];
			let jiaoyan = ((parameters.TABH[(random>>8)&0xff])<<8) + parameters.TABL[random&0xff];
			if (jiaoyan == resData) {
				resolve(1);
			}else{				
				uni.showToast({
					title: '发生未定义错误'
				});
				reject(0);
			}
		})
	}
	async function searchBoard(){					//读取控制板0号寄存器，判断控制板型号
		let res = await bleService.write(0x03,0x00,0x01);		
		boardType(res)
	}
	function boardType(e){							//控制板类型解析
		let i = 3;
		let boardres = e[i++]<<8 | e[i++];
		if(boardres == 0x3001){
			global.board = "ZN-WTA-01";
		}else if(boardres == 0x3012){
			global.board = "ZN-WTA-02";
		}
		console.log(global.board)
	}
	async function searchBaudRate(){				//波特率搜索
		global.searchBaud = 1;
		outerloop: for(let a = 0; a<serial.stopBitList_BLE.length; a++){
			for(let b = 0; b<serial.checkoutList_BLE.length; b++){				
				for(let c = 0; c<serial.baudRateList_BLE.length; c++){
					if(global.stopSearch){
						global.stopSearch = 0;
						return
					}
					serial.baudRate_BLE = serial.baudRateList_BLE[c].value;
					serial.checkout_BLE = serial.checkoutList_BLE[b].value;
					serial.stopBit_BLE = serial.stopBitList_BLE[a].value;					
					if(blue.advertisData == 'aa55'){
						await bleService.write_ztble(serial.baudRate_BLE,serial.checkout_BLE,serial.stopBit_BLE);				
					}else{
						await bleService.write_BLE();
					}									
					let res = await bleService.write(0x03,0x00,0x01);		//写0号寄存器看波特率等参数是否匹配，匹配成功则回复的数据长度为7			
					if(res.length == 7){
						let resData = res.slice(0,5);
						let crc = tool.getCRC16(resData,resData.length);
						if(crc == (res[5]<<8 | res[6])){							
							console.log('break')
							global.searchBaud = 0;
							break outerloop;
						}
					}else if(res == 1){
						console.log('continue')						
						continue;
					}
				}				
			}
		}		
	}
	function stopSearchBaudRate(){					//停止搜索波特率
		global.stopSearch = 1
		console.log('stopSearchBaudRate')		
	}
	function autoRead(e){							//自动读取
		global.autoread = 1;
		global.timer = setInterval(()=>{
			if(global.tabIndex == 1 && (global.board == "扭矩转速" || global.board == "ZN-TSA-01") && T_S.runMode == 0){
				TSAFunc.stateRead()
			}else if((global.tabIndex == 1 || global.tabIndex == 2) && global.board == "ZN-WTA-02"){
				WTA_read()
			}else if((global.tabIndex == 1 || global.tabIndex == 2) && global.board == "ZN-WTA-01"){
				WTA01_read()
			}else if((global.tabIndex == 1 || global.tabIndex == 2) && global.board == "ZN-RTD-01"){
				RTD_read()
			}else if(global.tabIndex == 1 && (global.board == "垃圾分类" || global.board == "垃圾分类N")){
				recycleFunc.stateRead()
			}else if(global.tabIndex == 2 && global.board == "垃圾分类N"){
				recycleFunc.state2Read()
			}else if(global.tabIndex == 1 && global.board == "模拟量采集"){
				A_read()
			}else if(global.tabIndex == 1 && global.board == "编码器"){
				encoderFunc.read()
			}else if(global.tabIndex == 1 && global.board == "ZDBL"){
				ZDBLFunc.stateRead()
			}			
		},500)
	}
	function closeRead(){							//关闭读取
		clearInterval(global.timer)
		global.autoread = 0
	}
	async function Reset(){							//WTA01_设备重启
		if(global.board == "模拟量采集"){
			await bleService.write(0x06,61,0xAA55)
			let res = await bleService.write(0x06,61,0x55AA)
			if(res.length){
				uni.showToast({
					title:'设备重启成功'
				})
			}else{
				uni.showToast({
					title:'设备重启失败'
				})
			}
		}else{
			let res = await bleService.write(0x06,0x9F,0xAA00);
			if(res.length){
				uni.showToast({
					title:'设备重启成功'
				})
			}else{
				uni.showToast({
					title:'设备重启失败'
				})
			}
		}		
	}
//串口1相关函数
	async function serialRead(){					//串口参数读取		
		let modbusRes = await bleService.write(0x03,0x40,0x03)
		modbusCanshu(modbusRes);		
	}
	async function serialWrite(){					//串口参数写入		
		let modbusData = [Number(serial.modbusId),
						Number((serial.reply << 8) | (serial.checkout << 2) | serial.stopBit),
						Number(serial.baudRate)						
						]		
		let modbusRes = await bleService.write(0x10,0x40,modbusData);
		if(modbusRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}		
	}
	function modbusCanshu(e){						//modbus参数解析
		let i = 3;
		serial.modbusId = e[i++]<<8 | e[i++];
		serial.reply = e[i++];
		serialConfig(e[i++]);
		serial.baudRate = e[i++]<<8 | e[i++];		
	}
	function serialConfig(e){						//modbus配置解析
		serial.stopBit = e & 0b00000011;
		serial.checkout = (e & 0b00001100)>>2;
	}
//串口2相关函数
	async function serialRead2(){					//串口参数读取		
		let modbusRes = await bleService.write(0x03,0x43,0x03)
		modbusCanshu2(modbusRes);
	}
	async function serialWrite2(){					//串口参数写入		
		let modbusData = [Number(serial.modbusId_2),
						Number((serial.reply_2 << 8) | (serial.port2 << 4) | (serial.checkout_2 << 2) | serial.stopBit_2),
						Number(serial.baudRate_2)						
						]		
		let modbusRes = await bleService.write(0x10,0x43,modbusData);		
		if(modbusRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	function modbusCanshu2(e){						//modbus参数解析
		let i = 3;
		serial.modbusId_2 = e[i++]<<8 | e[i++];
		serial.reply_2 = e[i++];
		serialConfig2(e[i++])		
		serial.baudRate_2 = e[i++]<<8 | e[i++];
	}
	function serialConfig2(e){						//modbus配置解析
		serial.stopBit_2 = e & 0b00000011;
		serial.checkout_2 = (e & 0b00001100)>>2;
		serial.port2 = (e & 0b00110000)>>4;
	}

//扭矩转速变送器相关函数
	const T_S = reactive({							//扭矩转速参数
		torque:1000,
		speed:1000,
		angle:0,
		location:0,
		pulse:0,
		warnList:parameters.WARN_RTD,
		warn:0,
		torqueDAC:0,
		speedDAC:0,
		torqueSet1:0,
		torqueSet2:10000,
		torqueReal1:null,
		torqueReal2:null,
		speedSet1:100,
		speedSet2:9000,
		speedReal1:null,
		speedReal2:null,
		torqueGain:1,
		torqueOffset:0,
		speedGain:1,
		speedOffset:0,
		frequencyOffset:0,
		torqueRange:200,
		speedRange:3000,
		angleRange:360,
		torque_k:100,
		speed_k:1,
		pulseSet:60,
		decimal_T:2,
		decimal_S:1,
		decimal_A:2,
		frequencyCutoff_T:1000,
		frequencyFilter_S:1000,
		runMode:0,
		modeList:[
					{ value: 0, text: "变频器模式" },
					{ value: 1, text: "DAC模式" }
				],
		type:0,
		typeList:[
					{ value: 0, text: "扭矩转速" },
					{ value: 1, text: "正交编码器" }
				],
		polarity_T:0,
		polarity_S:0,
		polarityList:parameters.POLARITY,
	})
	const TSAFunc = {
		open_DAC:async()=>{							//DAC打开
			await bleService.write(0x06,0x11,0x0001);
		},
		close_DAC:async()=>{						//DAC关闭
			await bleService.write(0x06,0x11,0x0000);
		},
		read_DAC:async()=>{							//DAC读取
			if(global.board == 'ZN-TSA-01'){
				let res = await bleService.write(0x03,0x20,0x02);
				TSAFunc.state_DAC(res)
			}else{
				let res = await bleService.write(0x03,0x24,0x02);
				TSAFunc.state_DAC(res)
			}
		},
		state_DAC:(e)=>{							//DAC参数解析
			let i = 3;
			T_S.torqueDAC = converter.ab2s16(e[i++],e[i++]);
			T_S.speedDAC = converter.ab2s16(e[i++],e[i++]);
		},
		write_DAC:async()=>{						//DAC写入
			if(global.board == 'ZN-TSA-01'){
				await bleService.write(0x10,0x20,[converter.s162ab(T_S.torqueDAC),converter.s162ab(T_S.speedDAC)]);	
			}else{
				await bleService.write(0x10,0x24,[converter.s162ab(T_S.torqueDAC),converter.s162ab(T_S.speedDAC)]);	
			}
		},
		stateRead:async()=>{						//T_S状态读取
			if(global.board == 'ZN-TSA-01'){
				let res = await bleService.write(0x04,0x00,0x0E);
				TSAFunc.state_ALL_TSA01(res)
			}else{
				let res = await bleService.write(0x03,0x00,0x02);
				TSAFunc.state_ALL(res)
			}
		},
		state_ALL:(e)=>{								//T_S状态解析
			let i = 3;
			T_S.torque = converter.ab2s16(e[i++],e[i++])/T_S.torque_k;
			T_S.speed = (e[i++]<<8 | e[i++])/T_S.speed_k;
		},
		state_ALL_TSA01:(e)=>{						//T_S状态解析
			let i = 3;
			T_S.torque = (converter.ab2s32(e[i++],e[i++],e[i++],e[i++])*tool.decimal(T_S.decimal_T)).toFixed(T_S.decimal_T < 0 ? 0 : T_S.decimal_T);
			T_S.speed = (converter.ab2s32(e[i++],e[i++],e[i++],e[i++])*tool.decimal(T_S.decimal_S)).toFixed(T_S.decimal_S < 0 ? 0 : T_S.decimal_S);
			T_S.angle = (converter.ab2s32(e[i++],e[i++],e[i++],e[i++])*tool.decimal(T_S.decimal_A)).toFixed(T_S.decimal_A < 0 ? 0 : T_S.decimal_A);
			T_S.pulse = converter.ab2s64(e[i++],e[i++],e[i++],e[i++],e[i++],e[i++],e[i++],e[i++])
			T_S.decimal_T = converter.ab2s16(e[i++],e[i++]);
			T_S.decimal_S = converter.ab2s16(e[i++],e[i++]);
			T_S.decimal_A = converter.ab2s16(e[i++],e[i++]);
			TSAFunc.warn((e[i++]<<8 | e[i++]));
		},
		warn:(e)=>{									//传感器故障解析
			let temp = [];
			for(let i = 0;i<16;i++){
				if(e&(1<<i)){
					temp.push(i)
				}
			}
			T_S.warn = temp;
		},
		sample_T1:async()=>{						//T_S转矩采样点1
			if(global.board == 'ZN-TSA-01'){
				await bleService.write(0x06,0x20,converter.s162ab(T_S.torqueSet1));
			}else{
				await bleService.write(0x06,0x24,converter.s162ab(T_S.torqueSet1));
			}		
			await bleService.write(0x06,0x9E,0x0001);
		},
		sample_T2:async()=>{						//T_S转矩采样点2
			if(global.board == 'ZN-TSA-01'){
				await bleService.write(0x06,0x20,converter.s162ab(T_S.torqueSet2));
			}else{
				await bleService.write(0x06,0x24,converter.s162ab(T_S.torqueSet2));
			}		
			await bleService.write(0x06,0x9E,0x0002);
		},
		check_T:async()=>{							//T_S转矩校准
			await bleService.write(0x10,0x80,[converter.s162ab(T_S.torqueReal1),converter.s162ab(T_S.torqueReal2)]);
			await bleService.write(0x06,0x9E,0x0004);		
		},
		sample_S1:async()=>{						//T_S转速采样点1
			if(global.board == 'ZN-TSA-01'){
				await bleService.write(0x06,0x21,converter.s162ab(T_S.speedSet1));
			}else{
				await bleService.write(0x06,0x25,converter.s162ab(T_S.speedSet1));
			}		
			await bleService.write(0x06,0x9E,0x0010);
		},
		sample_S2:async()=>{						//T_S转速采样点2
			if(global.board == 'ZN-TSA-01'){
				await bleService.write(0x06,0x21,converter.s162ab(T_S.speedSet2));
			}else{
				await bleService.write(0x06,0x25,converter.s162ab(T_S.speedSet2));
			}		
			await bleService.write(0x06,0x9E,0x0020);
		},
		check_S:async()=>{							//T_S转速校准
			await bleService.write(0x10,0x82,[converter.s162ab(T_S.speedReal1),converter.s162ab(T_S.speedReal2)]);
			await bleService.write(0x06,0x9E,0x0040);		
		},
		check_F:async()=>{							//T_S频率校准
			await bleService.write(0x06,0x9E,0x0100);		
		},
		check_close:async()=>{						//T_S取消校准
			await bleService.write(0x06,0x9E,0x0000);		
		},
		checkRead:async()=>{						//T_S校验参数读取
			if(global.board == 'ZN-TSA-01'){
				let checkRes = await bleService.write(0x03,0x60,0x0a)
				TSAFunc.param_check(checkRes);
			}else{
				let checkRes = await bleService.write(0x03,0x88,0x0a)
				TSAFunc.param_check(checkRes);
			}				
		},
		param_check:(e)=>{							//T_S校验参数解析
			let i = 3;		
			T_S.torqueGain = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			T_S.torqueOffset = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			T_S.speedGain = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			T_S.speedOffset = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			T_S.frequencyOffset = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		},
		checkWrite:async()=>{						//T_S校验参数写入
			let checkData = [...converter.float2ab(T_S.torqueGain),
							...converter.float2ab(T_S.torqueOffset),
							...converter.float2ab(T_S.speedGain),
							...converter.float2ab(T_S.speedOffset),
							...converter.float2ab(T_S.frequencyOffset)
							]
			if(global.board == 'ZN-TSA-01'){
				let checkRes = await bleService.write(0x10,0x60,checkData);
			}else{
				let checkRes = await bleService.write(0x10,0x88,checkData);
			}				
			if(checkRes.length){
				uni.showToast({
					title: '写入成功'
				});
			}else{
				uni.showToast({
					title: '写入失败'
				});
			}
		},
		sensorRead:async()=>{						//T_S传感器参数读取
			if(global.board == 'ZN-TSA-01'){
				let rangeRes = await bleService.write(0x03,0x50,0x0d)
				TSAFunc.param_sensor_TSA01(rangeRes);
			}else{
				let rangeRes = await bleService.write(0x03,0x30,0x05)
				TSAFunc.param_sensor(rangeRes);			
			}		
		},
		param_sensor_TSA01:(e)=>{					//T_S传感器参数解析
			let i = 3;
			T_S.runMode = e[i++]<<8 | e[i++];
			T_S.type = e[i++]<<8 | e[i++];
			T_S.torqueRange = e[i++]<<8 | e[i++];		
			T_S.speedRange = e[i++]<<8 | e[i++];
			T_S.angleRange = e[i++]<<8 | e[i++];
			T_S.pulseSet = e[i++]<<8 | e[i++];
			T_S.polarity_T = e[i++]<<8 | e[i++];
			T_S.polarity_S = e[i++]<<8 | e[i++];
			T_S.decimal_T = converter.ab2s16(e[i++],e[i++]);
			T_S.decimal_S = converter.ab2s16(e[i++],e[i++]);
			T_S.decimal_A = converter.ab2s16(e[i++],e[i++]);
			T_S.frequencyCutoff_T = e[i++]<<8 | e[i++];
			T_S.frequencyFilter_S = e[i++]<<8 | e[i++];
		},
		param_sensor:(e)=>{							//T_S传感器参数解析
			let i = 3;
			T_S.torqueRange = e[i++]<<8 | e[i++];		
			T_S.speedRange = e[i++]<<8 | e[i++];
			e[i++]<<8 | e[i++];
			T_S.pulseSet = e[i++]<<8 | e[i++];
			T_S.runMode = e[i++]<<8 | e[i++];		
		},
		sensorWrite:async()=>{						//T_S传感器参数写入
			if(global.board == 'ZN-TSA-01'){			
				let rangeData = [Number(T_S.runMode),
								Number(T_S.type),
								Number(T_S.torqueRange),
								Number(T_S.speedRange),
								Number(T_S.angleRange),
								Number(T_S.pulseSet),
								Number(T_S.polarity_T),
								Number(T_S.polarity_S),
								Number(T_S.decimal_T),
								Number(T_S.decimal_S),
								Number(T_S.decimal_A),
								Number(T_S.frequencyCutoff_T),
								Number(T_S.frequencyFilter_S),
								]
				let rangeRes = await bleService.write(0x10,0x50,rangeData);
				if(rangeRes.length){							
					uni.showToast({
						title: '写入成功'
					});
				}else{
					uni.showToast({
						title: '写入失败'
					});
				}
			}else{			
				let rangeData = [Number(T_S.torqueRange),
								Number(T_S.speedRange),
								Number(0),
								Number(T_S.pulseSet),
								Number(T_S.runMode)
								]			
				let rangeRes = await bleService.write(0x10,0x30,rangeData);			
				if(rangeRes.length){
					let torque_k = Math.round(32767/T_S.torqueRange)
					let speed_k = Math.round(32767/T_S.speedRange)			
					if(torque_k>=10000){
						T_S.torque_k = 10000				
					}else if(torque_k>=1000){
						T_S.torque_k = 1000				
					}else if(torque_k>=100){
						T_S.torque_k = 100				
					}else if(torque_k>=10){
						T_S.torque_k = 10				
					}else if(torque_k>=1){
						T_S.torque_k = 1				
					}
					if(speed_k>=10000){
						T_S.speed_k = 10000				
					}else if(speed_k>=1000){
						T_S.speed_k = 1000				
					}else if(speed_k>=100){
						T_S.speed_k = 100				
					}else if(speed_k>=10){
						T_S.speed_k = 10				
					}else if(speed_k>=1){
						T_S.speed_k = 1				
					}			
					uni.showToast({
						title: '写入成功'
					});
				}else{
					uni.showToast({
						title: '写入失败'
					});
				}
			}		
		},
		configRead:async()=>{						//T_S配置读取
			if(global.board == 'ZN-TSA-01'){			
				let modbusRes = await bleService.write(0x03,0x40,0x06)
				modbusCanshu12(modbusRes);
				let rangeRes = await bleService.write(0x03,0x50,0x0d)
				TSAFunc.param_sensor_TSA01(rangeRes);
			}else{
				let rangeRes = await bleService.write(0x03,0x30,0x05)
				TSAFunc.param_sensor(rangeRes);
				let modbusRes = await bleService.write(0x03,0x40,0x03)
				modbusCanshu(modbusRes);
			}
		},
		configWrite:async()=>{						//T_S配置写入
			if(global.board == 'ZN-TSA-01'){
				let modbusData = [Number(serial.modbusId),
								Number((serial.reply << 8) | (serial.checkout << 2) | serial.stopBit),
								Number(serial.baudRate),
								Number(serial.modbusId_2),
								Number((serial.reply_2 << 8) | (serial.port2 << 4) | (serial.checkout_2 << 2) | serial.stopBit_2),
								Number(serial.baudRate_2)
								]
				let rangeData = [Number(T_S.runMode),
								Number(T_S.type),
								Number(T_S.torqueRange),
								Number(T_S.speedRange),
								Number(T_S.angleRange),
								Number(T_S.pulseSet),
								Number(T_S.polarity_T),
								Number(T_S.polarity_S),
								Number(T_S.decimal_T),
								Number(T_S.decimal_S),
								Number(T_S.decimal_A),
								Number(T_S.frequencyCutoff_T),
								Number(T_S.frequencyFilter_S),
								]
				let modbusRes = await bleService.write(0x10,0x40,modbusData);
				let rangeRes = await bleService.write(0x10,0x50,rangeData);
				if(rangeRes.length){							
					uni.showToast({
						title: '写入成功'
					});
				}else{
					uni.showToast({
						title: '写入失败'
					});
				}
			}else{			
				let rangeData = [Number(T_S.torqueRange),
								Number(T_S.speedRange),
								Number(0),
								Number(T_S.pulseSet),
								Number(T_S.runMode)
								]
				let modbusData = [Number(serial.modbusId),
								Number(serial.checkout <<8 | serial.stopBit),
								Number(serial.baudRate),
								Number(serial.port2)
								]
				let rangeRes = await bleService.write(0x10,0x30,rangeData);
				let modbusRes = await bleService.write(0x10,0x40,modbusData);				
				if(modbusRes.length && rangeRes.length){
					let torque_k = Math.round(32767/T_S.torqueRange)
					let speed_k = Math.round(32767/T_S.speedRange)			
					if(torque_k>=10000){
						T_S.torque_k = 10000				
					}else if(torque_k>=1000){
						T_S.torque_k = 1000				
					}else if(torque_k>=100){
						T_S.torque_k = 100				
					}else if(torque_k>=10){
						T_S.torque_k = 10				
					}else if(torque_k>=1){
						T_S.torque_k = 1				
					}
					if(speed_k>=10000){
						T_S.speed_k = 10000				
					}else if(speed_k>=1000){
						T_S.speed_k = 1000				
					}else if(speed_k>=100){
						T_S.speed_k = 100				
					}else if(speed_k>=10){
						T_S.speed_k = 10				
					}else if(speed_k>=1){
						T_S.speed_k = 1				
					}			
					uni.showToast({
						title: '写入成功'
					});
				}else{
					uni.showToast({
						title: '写入失败'
					});
				}
			}		
		}		
	}
	async function save(){							//T_S配置保存		
		if(global.board == '垃圾分类'){
			let res = await bleService.write(0x06,0x24,0x01);
			if(res.length){
				uni.showToast({
					title:'保存成功'
				})
			}else{
				uni.showToast({
					title:'保存失败'
				})
			}
		}else{
			let res = await bleService.write(0x06,0x9F,0x0001);
			if(res.length){
				uni.showToast({
					title:'保存成功'
				})
			}else{
				uni.showToast({
					title:'保存失败'
				})
			}
		}		
	}
//双通道称重变送器相关函数
	async function WTA_read(){						//WTA_状态读取
		let res = await bleService.write(0x04,0x00,0x0a);		
		WTA_allState(res)
	}
	function WTA_allState(e){						//WTA_状态解析
		let i = 3;			
		WTA.weight1 = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
		WTA.weight2 = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);
		//WTA.warn1 = (e[i++]<<8 | e[i++]);
		WTA_warn1((e[i++]<<8 | e[i++]));
		//WTA.warn2 = (e[i++]<<8 | e[i++]);
		WTA_warn2((e[i++]<<8 | e[i++]));
		WTA.current1 = (e[i++]<<8 | e[i++])/10;
		WTA.current2 = (e[i++]<<8 | e[i++])/10;
		WTA.temperature1 = converter.ab2s16(e[i++],e[i++])/10;
		WTA.temperature2 = converter.ab2s16(e[i++],e[i++])/10;		
	}
	function WTA_warn1 (e) { 							//WTA_传感器1故障解析
		let temp = [];
		for(let i = 0;i<16;i++){
			if(e&(1<<i)){
				temp.push(i)
			}
		}
		WTA.warn1 = temp;
	}
	function WTA_warn2 (e) { 							//WTA_传感器2故障解析
		let temp = [];
		for(let i = 0;i<16;i++){
			if(e&(1<<i)){
				temp.push(i)
			}
		}
		WTA.warn2 = temp;
	}
	async function WTA_clear(){						//WTA_清零		
		await bleService.write(0x06,0x9E,0x01);
	}
	async function WTA_check(){						//WTA_校准		
		await bleService.write(0x06,0x31,WTA.weightSet);
		await bleService.write(0x06,0x9E,0x02);
	}
	async function WTA_DACSample1(){					//WTA_DAC采样点1
		await bleService.write(0x06,0x30,converter.s162ab(WTA.DACset1));
		await bleService.write(0x06,0x9E,0x10);		
	}
	async function WTA_DACSample2(){					//WTA_DAC采样点2		
		await bleService.write(0x06,0x30,converter.s162ab(WTA.DACset2));
		await bleService.write(0x06,0x9E,0x20);		
	}
	async function WTA_DACCheck(){					//WTA_DAC校准		
		await bleService.write(0x10,0x32,[converter.s162ab(WTA.DACReal1),converter.s162ab(WTA.DACReal2)]);
		await bleService.write(0x06,0x9E,0x40);
	}
	async function WTA_checkRead(){					//WTA_校验参数读取		
		let checkRes = await bleService.write(0x03,0x60,0x08)
		WTA_checkCanshu(checkRes);		
	}
	async function WTA_checkWrite(){					//WTA_校验参数写入		
		let checkData = [...converter.float2ab(WTA.weightGain),
						...converter.float2ab(WTA.weightOffset),
						...converter.float2ab(WTA.DACGain),
						...converter.float2ab(WTA.DACOffset)						
						]				
		let checkRes = await bleService.write(0x10,0x60,checkData);		
		if(checkRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function WTA_sensorRead(){					//WTA_传感器参数读取		
		let sensorRes = await bleService.write(0x03,0x51,0x01)
		WTA_sensorCanshu(sensorRes);				
	}
	function WTA_sensorCanshu(e){						//WTA_传感器参数解析
		let i = 3;
		WTA.polarity = e[i++];
		WTA_Config(e[i++]);		
	}
	async function WTA_sensorWrite(){					//WTA_传感器参数写入				
		let sensorData = Number(WTA.polarity<<8 | WTA.mult<<4 | WTA.sampleRate)		
		let sensorRes = await bleService.write(0x06,0x51,sensorData);				
		if(sensorRes.length){						
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function WTA_weightRead(){					//WTA_重量参数读取
		let weightRes = await bleService.write(0x03,0x52,0x03)
		WTA_weightCanshu(weightRes);
	}
	function WTA_weightCanshu(e){						//WTA_重量参数解析
		let i = 3;					
		WTA.weightRange = e[i++]<<8 | e[i++];
		WTA.weightUnit = e[i++]<<8 | e[i++];
		WTA.current_normal = (e[i++]<<8 | e[i++])/10;
	}
	async function WTA_weightWrite(){					//WTA_重量参数写入				
		let weightData = [Number(WTA.weightRange),
						Number(WTA.weightUnit),
						Number(WTA.current_normal*10)
						]
		
		let weightRes = await bleService.write(0x10,0x52,weightData);				
		if(weightRes.length){						
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function WTA_readConfig(){					//WTA_配置读取
		let modbusRes = await bleService.write(0x03,0x40,0x03)
		modbusCanshu(modbusRes);
		let rangeRes = await bleService.write(0x03,0x51,0x04)
		WTA_rangeCanshu(rangeRes);				
	}
	function WTA_rangeCanshu(e){						//WTA_传感器参数解析
		let i = 3;
		WTA.polarity = e[i++];
		WTA_Config(e[i++]);			
		WTA.weightRange = e[i++]<<8 | e[i++];
		WTA.weightUnit = e[i++]<<8 | e[i++];
		WTA.current_normal = (e[i++]<<8 | e[i++])/10;
	}
	function WTA_Config(e){							//WTA_配置解析
		WTA.mult = (e & 0xf0)>>4;
		WTA.sampleRate = e & 0x0f;
	}
	function WTA_checkCanshu(e){						//WTA_校验参数解析
		let i = 3;		
		WTA.weightGain = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		WTA.weightOffset = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		WTA.DACGain = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		WTA.DACOffset = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);		
	}
	async function WTA_write(){						//WTA_配置写入
		let modbusData = [Number(serial.modbusId),
						Number(serial.checkout <<8 | serial.stopBit),
						Number(serial.baudRate)						
						]		
		let rangeData = [Number(WTA.polarity<<8 | WTA.mult<<4 | WTA.sampleRate),
						Number(WTA.weightRange),
						Number(WTA.weightUnit),
						Number(WTA.current_normal*10)
						]		
		let modbusRes = await bleService.write(0x10,0x40,modbusData);
		let rangeRes = await bleService.write(0x10,0x51,rangeData);		
		if(modbusRes.length && rangeRes.length){						
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
//单通道称重变送器相关函数
	async function WTA01_read(){						//WTA01_状态读取
		let res = await bleService.write(0x04,0x00,0x05);		
		WTA01_allState(res)
	}
	function WTA01_allState(e){						//WTA01_状态解析
		let i = 3;			
		WTA.weight1 = converter.ab2s32(e[i++],e[i++],e[i++],e[i++]);		
		WTA.warn1 = (e[i++]<<8 | e[i++]);
		WTA_warn1(WTA.warn1);
		WTA.current1 = (e[i++]<<8 | e[i++])/10;
		WTA.temperature1 = converter.ab2s16(e[i++],e[i++])/10;
	}
	async function WTA01_clear(){						//WTA01_清零		
		await bleService.write(0x06,0x15,0x01);
	}
	async function WTA01_check(){						//WTA01_校准		
		let checkData = [...converter.s322ab(WTA.weightSet)]
		console.log(checkData,'checkData')
		await bleService.write(0x10,0x17,checkData);
		await bleService.write(0x06,0x15,0x02);
	}
	async function WTA01_checkRead(){					//WTA01_校验参数读取		
		let checkRes = await bleService.write(0x03,0x20,0x04)
		WTA01_checkCanshu(checkRes);		
	}
	function WTA01_checkCanshu(e){					//WTA01_校验参数解析
		let i = 3;		
		WTA.weightGain = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		WTA.weightOffset = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);		
	}
	async function WTA01_checkWrite(){				//WTA01_校验参数写入		
		let checkData = [...converter.float2ab(WTA.weightGain),
						...converter.float2ab(WTA.weightOffset)												
						]				
		let checkRes = await bleService.write(0x10,0x20,checkData);		
		if(checkRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function WTA01_serialRead(){				//WTA01_串口参数读取		
		let modbusRes = await bleService.write(0x03,0x19,0x03)
		WTA01_modbusCanshu(modbusRes);
	}
	async function WTA01_serialWrite(){				//WTA01_串口参数写入		
		let modbusData = [Number(serial.modbusId),
						0,
						Number(serial.baudRate)						
						]		
		let modbusRes = await bleService.write(0x10,0x19,modbusData);		
		if(modbusRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	function WTA01_modbusCanshu(e){					//modbus参数解析
		let i = 3;
		serial.modbusId = e[i++]<<8 | e[i++];
		e[i++];
		e[i++];
		serial.baudRate = e[i++]<<8 | e[i++];		
	}
	async function WTA01_sensorRead(){				//WTA01_传感器参数读取		
		let sensorRes = await bleService.write(0x03,0x1D,0x01)
		WTA01_sensorCanshu(sensorRes);				
	}
	function WTA01_sensorCanshu(e){					//WTA01_传感器参数解析
		let i = 3;
		e[i++];
		WTA.sampleRate = e[i++] & 0x0f;
	}
	async function WTA01_sensorWrite(){				//WTA01_传感器参数写入				
		let sensorData = Number(WTA.sampleRate)		
		let sensorRes = await bleService.write(0x06,0x1D,sensorData);				
		if(sensorRes.length){						
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function WTA01_weightRead(){				//WTA01_重量参数读取
		let weightRes = await bleService.write(0x03,0x1E,0x02)		
		WTA01_weightCanshu(weightRes);
	}
	function WTA01_weightCanshu(e){					//WTA01_重量参数解析
		let i = 3;
		let weight_data = e[i++]<<8 | e[i++];		
		WTA.current_normal = (e[i++]<<8 | e[i++])/10;		
		let weightArray = weightUnit.map((item)=>{
			return item.value
		})
		console.log(weightArray,'weightArray')
		if(weightArray.indexOf(weight_data)==-1){
			console.log("重量单位超限")
		}else{
			WTA.weightUnit = weight_data
		}		
	}
	async function WTA01_weightWrite(){				//WTA01_重量参数写入				
		let weightData = [Number(WTA.weightUnit),
						Number(WTA.current_normal*10)
						]
		let weightRes = await bleService.write(0x10,0x1E,weightData);				
		if(weightRes.length){						
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function WTA01_readConfig(){				//WTA01_配置读取
		let modbusRes = await bleService.write(0x03,0x19,0x03)
		WTA01_modbusCanshu(modbusRes);
		let sensorRes = await bleService.write(0x03,0x1D,0x01)
		WTA01_sensorCanshu(sensorRes);
		let weightRes = await bleService.write(0x03,0x1E,0x02)
		WTA01_weightCanshu(weightRes);				
	}
	async function WTA01_write(){						//WTA01_配置写入
		let modbusData = [Number(serial.modbusId),
						0,
						Number(serial.baudRate)
						]
		let sensorData = Number(WTA.sampleRate)
		
		let weightData = [Number(WTA.weightUnit),
						Number(WTA.current_normal*10)
						]		
		let modbusRes = await bleService.write(0x10,0x19,modbusData);
		let sensorRes = await bleService.write(0x06,0x1D,sensorData);
		let weightRes = await bleService.write(0x10,0x1E,weightData);		
		if(modbusRes.length && sensorRes.length && weightRes.length){						
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function WTA01_save(){							//WTA01_配置保存		
		let res = await bleService.write(0x06,0x9F,0x0001);		
		if(res.length){
			uni.showToast({
				title:'保存成功'
			})
		}else{
			uni.showToast({
				title:'保存失败'
			})
		}
	}
//温度变送器相关函数
	async function RTD_read(){						//RTD_状态读取
		let res = await bleService.write(0x04,0x00,0x04);		
		RTD_allState(res)
	}
	function RTD_allState(e){						//RTD_状态解析
		let i = 3;
		RTD.temperature = converter.ab2s16(e[i++],e[i++])/10;		
		//RTD.warn = (e[i++]<<8 | e[i++]);
		RTD_warn((e[i++]<<8 | e[i++]));
		RTD.chipTemperature = converter.ab2s16(e[i++],e[i++])/10;
		RTD.resistance = (e[i++]<<8 | e[i++])/10;
	}
	function RTD_warn (e) { 							//WTA_传感器1故障解析
		let temp = [];
		for(let i = 0;i<16;i++){
			if(e&(1<<i)){
				temp.push(i)
			}
		}
		RTD.warn = temp;
	}
	async function RTD_ResSample1(){						//WTA_清零
		await bleService.write(0x06,0x31,RTD.resset1);
		await bleService.write(0x06,0x9E,0x01);
	}
	async function RTD_ResSample2(){						//WTA_校准		
		await bleService.write(0x06,0x31,RTD.resset2);
		await bleService.write(0x06,0x9E,0x02);
	}
	async function RTD_DACSample1(){					//WTA_DAC采样点1
		await bleService.write(0x06,0x30,converter.s162ab(RTD.DACset1));
		if(global.current == 0){						//0-10V
			await bleService.write(0x06,0x9E,0x10);
		}else if(global.current == 1){					//0-5V
			await bleService.write(0x06,0x9E,0x100);
		}
		else if(global.current == 2){					//4-20mA
			await bleService.write(0x06,0x9E,0x1000);
		}		
	}
	async function RTD_DACSample2(){					//WTA_DAC采样点2		
		await bleService.write(0x06,0x30,converter.s162ab(RTD.DACset2));
		if(global.current == 0){						//0-10V
			await bleService.write(0x06,0x9E,0x20);
		}else if(global.current == 1){					//0-5V
			await bleService.write(0x06,0x9E,0x200);
		}
		else if(global.current == 2){					//4-20mA
			await bleService.write(0x06,0x9E,0x2000);
		}
	}
	async function RTD_DACCheck(){					//WTA_DAC校准		
		await bleService.write(0x10,0x32,[converter.s162ab(RTD.DACReal1),converter.s162ab(RTD.DACReal2)]);
		if(global.current == 0){						//0-10V
			await bleService.write(0x06,0x9E,0x40);
		}else if(global.current == 1){					//0-5V
			await bleService.write(0x06,0x9E,0x400);
		}
		else if(global.current == 2){					//4-20mA
			await bleService.write(0x06,0x9E,0x4000);
		}
	}
	async function RTD_checkRead(){					//WTA_校验参数读取
		let checkRes = await bleService.write(0x03,0x60,0x10)
		RTD_checkCanshu(checkRes);
	}
	async function RTD_checkWrite(){					//WTA_校验参数写入		
		let checkData = [...converter.float2ab(RTD.ADCGain),
						...converter.float2ab(RTD.ADCOffset),
						...converter.float2ab(RTD.DACGain_10V),
						...converter.float2ab(RTD.DACOffset_10V),
						...converter.float2ab(RTD.DACGain_5V),
						...converter.float2ab(RTD.DACOffset_5V),
						...converter.float2ab(RTD.DACGain_20mA),
						...converter.float2ab(RTD.DACOffset_20mA),
						]				
		let checkRes = await bleService.write(0x10,0x60,checkData);		
		if(checkRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	function RTD_checkCanshu(e){						//WTA_校验参数解析
		let i = 3;		
		RTD.ADCGain = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		RTD.ADCOffset = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		RTD.DACGain_10V = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		RTD.DACOffset_10V = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);		
		RTD.DACGain_5V = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		RTD.DACOffset_5V = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		RTD.DACGain_20mA = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		RTD.DACOffset_20mA = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
	}
	async function RTD_sensorRead(){					//WTA_传感器参数读取		
		let sensorRes = await bleService.write(0x03,0x50,0x04)
		RTD_sensorCanshu(sensorRes);				
	}
	function RTD_sensorCanshu(e){						//WTA_传感器参数解析
		let i = 3;		
		RTD.analogRange = e[i++];
		RTD.sensor = e[i++];
		e[i++];
		RTD.sampleRate = e[i++] & 0x0f;		
		RTD.temperature_min = (e[i++]<<8 | e[i++]);
		RTD.temperature_max = (e[i++]<<8 | e[i++]);			
	}	
	async function RTD_sensorWrite(){					//WTA_传感器参数写入				
		let sensorData = [	Number(RTD.analogRange<<8 | RTD.sensor),
							Number(RTD.sampleRate),
							Number(RTD.temperature_min),
							Number(RTD.temperature_max)
						]		
		let sensorRes = await bleService.write(0x10,0x50,sensorData);				
		if(sensorRes.length){						
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function RTD_readConfig(){					//WTA_配置读取		
		let modbusRes = await bleService.write(0x03,0x40,0x06)
		modbusCanshu12(modbusRes);		
		let sensorRes = await bleService.write(0x03,0x50,0x04)
		RTD_sensorCanshu(sensorRes);						
	}
	function modbusCanshu12(e){						//modbus参数解析
		let i = 3;
		serial.modbusId = e[i++]<<8 | e[i++];
		serial.reply = e[i++];
		serialConfig(e[i++]);
		serial.baudRate = e[i++]<<8 | e[i++];
		serial.modbusId_2 = e[i++]<<8 | e[i++];
		serial.reply_2 = e[i++];
		serialConfig2(e[i++])		
		serial.baudRate_2 = e[i++]<<8 | e[i++];
	}
	async function RTD_write(){						//WTA_配置写入
		let modbusData = [Number(serial.modbusId),
						Number((serial.reply << 8) | (serial.checkout << 2) | serial.stopBit),
						Number(serial.baudRate),
						Number(serial.modbusId_2),
						Number((serial.reply_2 << 8) | (serial.port2 << 4) | (serial.checkout_2 << 2) | serial.stopBit_2),
						Number(serial.baudRate_2)
						]		
		let rangeData = [Number(RTD.analogRange<<8 | RTD.sensor),
						Number(RTD.sampleRate),
						Number(RTD.temperature_min),
						Number(RTD.temperature_max)
						]		
		let modbusRes = await bleService.write(0x10,0x40,modbusData);
		let rangeRes = await bleService.write(0x10,0x50,rangeData);
		if(modbusRes.length && rangeRes.length){						
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
//模拟量采集模块相关函数
	async function A_read(){						//通道状态读取
		let res = await bleService.write(0x04,0x00,0x04);		
		A_allState(res)
	}
	function A_allState(e){							//通道状态解析
		let i = 3;
		let ad0 = converter.ab2s16(e[i++],e[i++]);
		let ad1 = converter.ab2s16(e[i++],e[i++]);
		let ad2 = converter.ab2s16(e[i++],e[i++]);
		let ad3 = converter.ab2s16(e[i++],e[i++]);		
		if(analog.range == 0){
			if(analog.ad0_mode == 0){
				analog.ad0 = (5*ad0/16384).toFixed(4);
			}else if(analog.ad0_mode == 1){
				analog.ad0 = (20*ad0/16384).toFixed(4);
			}
			if(analog.ad1_mode == 0){
				analog.ad1 = (5*ad1/16384).toFixed(4);
			}else if(analog.ad1_mode == 1){
				analog.ad1 = (20*ad1/16384).toFixed(4);
			}
			if(analog.ad2_mode == 0){
				analog.ad2 = (5*ad2/16384).toFixed(4);
			}else if(analog.ad2_mode == 1){
				analog.ad2 = (20*ad2/16384).toFixed(4);
			}
			if(analog.ad3_mode == 0){
				analog.ad3 = (5*ad3/16384).toFixed(4);
			}else if(analog.ad3_mode == 1){
				analog.ad3 = (20*ad3/16384).toFixed(4);
			}
		}else if(analog.range == 1){
			analog.ad0 = ad0;
			analog.ad1 = ad1;
			analog.ad2 = ad2;
			analog.ad3 = ad3;
		}		
	}
	async function A_modeRead(){						//通道类型读取
		let res = await bleService.write(0x03,280,4);		
		console.log(res,'A_modeRead')
		A_modeStatus(res)
	}
	async function A_modeWrite(){						//通道类型写入
		let modeData = [Number(analog.ad0_mode),
						Number(analog.ad1_mode),
						Number(analog.ad2_mode),
						Number(analog.ad3_mode)	
						]
		let modeRes = await bleService.write(0x10,280,modeData);		
		if(modeRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	function A_modeStatus(e){
		let i =3;
		analog.ad0_mode = (e[i++]<<8 | e[i++]);
		analog.ad1_mode = (e[i++]<<8 | e[i++]);
		analog.ad2_mode = (e[i++]<<8 | e[i++]);
		analog.ad3_mode = (e[i++]<<8 | e[i++]);
	}
	async function A_checkAll(e){						//不经check，check后e传不过来		
		if(e.detail.value){
			analog.check_all = 1;
			console.log(analog.check_all,'analog.check_all')
			await bleService.write(0x06,120,Number(analog.check_all));
		}else{
			analog.check_all = 0;
			console.log(analog.check_all,'analog.check_all')
			await bleService.write(0x06,120,Number(analog.check_all));
		}		
	}
	async function ad0_sample1(){					//ad0采样点1		
		if(analog.ad0_mode == 0){
			await bleService.write(0x06,121,converter.s162ab(analog.ad0_real1*16384/5));
		}else if(analog.ad0_mode == 1){
			await bleService.write(0x06,200,converter.s162ab(analog.ad0_real1_A*16384/20));
		}		
	}
	async function ad0_sample2(){					//ad0采样点2
		if(analog.ad0_mode == 0){
			await bleService.write(0x06,122,converter.s162ab(analog.ad0_real2*16384/5));
		}else if(analog.ad0_mode == 1){
			await bleService.write(0x06,201,converter.s162ab(analog.ad0_real2_A*16384/20));
		}
	}
	async function ad0_read(){					//ad0校验参数读取
		if(analog.ad0_mode == 0){
			let checkData = await bleService.write(0x03,123,0x04);
			ad0_checkData(checkData);
		}else if(analog.ad0_mode == 1){
			let checkData = await bleService.write(0x03,202,0x04);
			ad0_checkData(checkData);
		}
		
	}
	function ad0_checkData(e){
		let i = 3;
		if(analog.ad0_mode == 0){
			analog.ad0_k = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			analog.ad0_b = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		}else if(analog.ad0_mode == 1){
			analog.ad0_k_A = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			analog.ad0_b_A = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		}
	}
	async function ad0_write(){					//ad0校验参数写入
		if(analog.ad0_mode == 0){
			let checkData = [
								...converter.float2ab(analog.ad0_k),
								...converter.float2ab(analog.ad0_b)
							]					
			let checkRes = await bleService.write(0x10,123,checkData);
		}else if(analog.ad0_mode == 1){
			let checkData = [
								...converter.float2ab(analog.ad0_k_A),
								...converter.float2ab(analog.ad0_b_A)
							]					
			let checkRes = await bleService.write(0x10,202,checkData);
		}		
		if(checkRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}			
	}
	async function ad1_sample1(){					//ad1采样点1
		if(analog.ad1_mode == 0){
			await bleService.write(0x06,127,converter.s162ab(analog.ad1_real1*16384/5));
		}else if(analog.ad1_mode == 1){
			await bleService.write(0x06,206,converter.s162ab(analog.ad1_real1_A*16384/20));
		}		
	}
	async function ad1_sample2(){					//ad1采样点2
		if(analog.ad1_mode == 0){
			await bleService.write(0x06,128,converter.s162ab(analog.ad1_real2*16384/5));
		}else if(analog.ad1_mode == 1){
			await bleService.write(0x06,207,converter.s162ab(analog.ad1_real2_A*16384/20));
		}
	}
	async function ad1_read(){					//ad1校验参数读取
		if(analog.ad1_mode == 0){
			let checkData = await bleService.write(0x03,129,0x04);
			ad1_checkData(checkData);
		}else if(analog.ad1_mode == 1){
			let checkData = await bleService.write(0x03,208,0x04);
			ad1_checkData(checkData);
		}		
	}
	function ad1_checkData(e){
		let i = 3;
		if(analog.ad1_mode == 0){
			analog.ad1_k = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			analog.ad1_b = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		}else if(analog.ad1_mode == 1){
			analog.ad1_k_A = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			analog.ad1_b_A = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		}
	}
	async function ad1_write(){					//ad1校验参数写入
		if(analog.ad1_mode == 0){
			let checkData = [
								...converter.float2ab(analog.ad1_k),
								...converter.float2ab(analog.ad1_b)
							]					
			let checkRes = await bleService.write(0x10,129,checkData);
		}else if(analog.ad1_mode == 1){
			let checkData = [
								...converter.float2ab(analog.ad1_k_A),
								...converter.float2ab(analog.ad1_b_A)
							]					
			let checkRes = await bleService.write(0x10,208,checkData);
		}		
		if(checkRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}			
	}
	async function ad2_sample1(){					//ad2采样点1
		if(analog.ad2_mode == 0){
			await bleService.write(0x06,133,converter.s162ab(analog.ad2_real1*16384/5));
		}else if(analog.ad2_mode == 1){
			await bleService.write(0x06,212,converter.s162ab(analog.ad2_real1_A*16384/20));
		}		
	}
	async function ad2_sample2(){					//ad2采样点2
		if(analog.ad2_mode == 0){
			await bleService.write(0x06,134,converter.s162ab(analog.ad2_real2*16384/5));
		}else if(analog.ad2_mode == 1){
			await bleService.write(0x06,213,converter.s162ab(analog.ad2_real2_A*16384/20));
		}
	}
	async function ad2_read(){					//ad2校验参数读取
		if(analog.ad2_mode == 0){
			let checkData = await bleService.write(0x03,135,0x04);	
			ad2_checkData(checkData);
		}else if(analog.ad2_mode == 1){
			let checkData = await bleService.write(0x03,214,0x04);
			ad2_checkData(checkData);
		}		
	}
	function ad2_checkData(e){
		let i = 3;
		if(analog.ad2_mode == 0){
			analog.ad2_k = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			analog.ad2_b = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		}else if(analog.ad2_mode == 1){
			analog.ad2_k_A = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			analog.ad2_b_A = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		}
	}
	async function ad2_write(){					//ad2校验参数写入
		if(analog.ad2_mode == 0){
			let checkData = [
								...converter.float2ab(analog.ad2_k),
								...converter.float2ab(analog.ad2_b)
							]					
			let checkRes = await bleService.write(0x10,135,checkData);
		}else if(analog.ad2_mode == 1){
			let checkData = [
								...converter.float2ab(analog.ad2_k_A),
								...converter.float2ab(analog.ad2_b_A)
							]					
			let checkRes = await bleService.write(0x10,214,checkData);
		}		
		if(checkRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}			
	}
	async function ad3_sample1(){					//ad3采样点1
		if(analog.ad3_mode == 0){
			await bleService.write(0x06,139,converter.s162ab(analog.ad3_real1*16384/5));
		}else if(analog.ad3_mode == 1){
			await bleService.write(0x06,218,converter.s162ab(analog.ad3_real1_A*16384/20));
		}		
	}
	async function ad3_sample2(){					//ad3采样点2
		if(analog.ad3_mode == 0){
			await bleService.write(0x06,140,converter.s162ab(analog.ad3_real2*16384/5));
		}else if(analog.ad3_mode == 1){
			await bleService.write(0x06,219,converter.s162ab(analog.ad3_real2_A*16384/20));
		}
	}
	async function ad3_read(){					//ad3校验参数读取
		if(analog.ad3_mode == 0){
			let checkData = await bleService.write(0x03,141,0x04);
			ad3_checkData(checkData);
		}else if(analog.ad3_mode == 1){
			let checkData = await bleService.write(0x03,220,0x04);
			ad3_checkData(checkData);
		}		
	}
	function ad3_checkData(e){
		let i = 3;
		if(analog.ad3_mode == 0){
			analog.ad3_k = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			analog.ad3_b = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		}else if(analog.ad3_mode == 1){
			analog.ad3_k_A = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
			analog.ad3_b_A = converter.ab2float(e[i++],e[i++],e[i++],e[i++]);
		}
	}
	async function ad3_write(){					//ad3校验参数写入
		if(analog.ad3_mode == 0){
			let checkData = [
								...converter.float2ab(analog.ad3_k),
								...converter.float2ab(analog.ad3_b)
							]					
			let checkRes = await bleService.write(0x10,141,checkData);
		}else if(analog.ad3_mode == 1){
			let checkData = [
								...converter.float2ab(analog.ad3_k_A),
								...converter.float2ab(analog.ad3_b_A)
							]					
			let checkRes = await bleService.write(0x10,220,checkData);
		}		
		if(checkRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}			
	}
	async function A_frequencyRead(){					//频率参数读取
		let frequencyRes = await bleService.write(0x03,100,0x05)
		A_frequencyCanshu(frequencyRes);
	}
	function A_frequencyCanshu(e){
		let i = 3;
		serial.uploadFrequency = converter.ab2s16(e[i++],e[i++])/10;
		analog.offFrequency_AD0 = converter.ab2s16(e[i++],e[i++])/10;
		analog.offFrequency_AD1 = converter.ab2s16(e[i++],e[i++])/10;
		analog.offFrequency_AD2 = converter.ab2s16(e[i++],e[i++])/10;
		analog.offFrequency_AD3 = converter.ab2s16(e[i++],e[i++])/10;
	}
	async function A_frequencyWrite(){					//频率参数写入
		let frequencyData = [converter.s162ab(serial.uploadFrequency*10),
						converter.s162ab(analog.offFrequency_AD0*10),
						converter.s162ab(analog.offFrequency_AD1*10),
						converter.s162ab(analog.offFrequency_AD2*10),
						converter.s162ab(analog.offFrequency_AD3*10)
						]		
		let frequencyRes = await bleService.write(0x10,100,frequencyData);		
		if(frequencyRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function A_outputRead(){					//频率参数读取
		let outputRes = await bleService.write(0x03,320,0x04)
		A_outputCanshu(outputRes);
	}
	function A_outputCanshu(e){
		let i = 3;
		analog.ad0_out = (e[i++]<<8 | e[i++]);
		analog.ad1_out = (e[i++]<<8 | e[i++]);
		analog.ad2_out = (e[i++]<<8 | e[i++]);
		analog.ad3_out = (e[i++]<<8 | e[i++]);		
	}
	async function A_outputWrite(){					//频率参数写入
		let outputData = [Number(analog.ad0_out),
						Number(analog.ad1_out),
						Number(analog.ad2_out),
						Number(analog.ad3_out)	
						]		
		let outputRes = await bleService.write(0x10,320,outputData);		
		if(outputRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function A_serialRead(){					//串口参数读取
		let modbusRes = await bleService.write(0x03,80,0x03)
		A_modbusCanshu(modbusRes);
	}	
	function A_modbusCanshu(e){						//modbus参数解析
		let i = 3;
		e[i++];
		A_configData(e[i++]);
		e[i++];
		serial.modbusId = e[i++];
		e[i++];
		serial.reply = e[i++];
	}
	function A_configData(e){
		serial.stopBit = (e&0b11000000)>>6;
		serial.checkout = (e&0b00110000)>>4;
		serial.baudRate = e&0b00001111;
	}
	async function A_serialWrite(){					//串口参数写入
		let modbusData = [Number(serial.stopBit << 6 | serial.checkout << 4 | serial.baudRate),
						Number(serial.modbusId),
						Number(serial.reply)						
						]		
		let modbusRes = await bleService.write(0x10,80,modbusData);		
		if(modbusRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}	
	async function A_serialRead2(){					//串口参数读取		
		let modbusRes = await bleService.write(0x03,83,0x03)
		A_modbusCanshu2(modbusRes);
	}	
	function A_modbusCanshu2(e){						//modbus参数解析
		let i = 3;		
		A_configData2(e[i++],e[i++]);
		e[i++];
		serial.modbusId_2 = e[i++];
		e[i++];
		serial.reply_2 = e[i++];
	}
	function A_configData2(a,b){
		serial.follow = (a&0b10000000)>>7;
		serial.mode = a&0b01111111;
		serial.stopBit_2 = (b&0b11000000)>>6;
		serial.checkout_2 = (b&0b00110000)>>4;
		serial.baudRate_2 = b&0b00001111;
	}
	async function A_serialWrite2(){					//串口参数写入
		let modbusData = [Number(serial.follow << 15 | serial.mode << 8 | serial.stopBit_2 << 6 | serial.checkout_2 << 4 | serial.baudRate_2),
						Number(serial.modbusId_2),
						Number(serial.reply_2)						
						]		
		let modbusRes = await bleService.write(0x10,83,modbusData);		
		if(modbusRes.length){
			uni.showToast({
				title: '写入成功'
			});
		}else{
			uni.showToast({
				title: '写入失败'
			});
		}
	}
	async function A_serialFollow(e){						//不经check，check后e传不过来
		if(e.detail.value){
			serial.follow = 1;
		}else{
			serial.follow = 0;
		}
	}
//蓝牙相关函数
	const bleService = {
		/* write:(code,addres,data)=>{		//封装promise，解决嵌套问题
			return new Promise((resolve,reject)=>{
				if(!blue.connected){
					uni.showToast({	title:'请先连接蓝牙',	icon:'none'})
					return
				}
				if(global.writeOK){						//确保一次收发数据完成
					global.timeout = setTimeout(()=>{//超时确保能进行下一次收发数据
						global.writeOK = 0
					},500)
					return
				}
				global.writeOK = 1
				clearTimeout(global.timeout);
				blue.resLength = 8;
				if(code == 0x03 || code == 0x04){
					blue.resLength = 5+2*Number(data);
				}
				console.log(blue.resLength,'blue.resLength')
				let sendData = [];
				let i = 0;
				sendData[i++] = serial.slave_id;
				sendData[i++] = code;
				sendData[i++] = addres>>8;
				sendData[i++] = addres;
				if (code == 0x10) {						//写多个寄存器
					sendData[i++] = data.length>>8;
					sendData[i++] = data.length;
					sendData[i++] = data.length*2;
					for(let j=0;j<data.length;j+2){
						sendData[i++] = data[j]>>8;
						sendData[i++] = data[j++]&0xff;
					}
				} else{									//读/写单个寄存器
					sendData[i++] = data>>8;
					sendData[i++] = data&0xff;
				}
				let crc = tool.getCRC16(sendData,sendData.length);	//CRC校验
				sendData[i++] = crc >> 8;
				sendData[i++] = crc & 0xff;
				let buffer = new ArrayBuffer(sendData.length)
				let s_data = new Uint8Array(buffer)
				for(let i=0;i<sendData.length;i++){
					s_data[i] = sendData[i];
				}
				blue.sendData = buffer;
				uni.writeBLECharacteristicValue({				//写
					deviceId: blue.deviceId,
					serviceId: blue.serviceId,
					characteristicId: blue.characteristicId,
					value: buffer,
					complete:(e)=>{
						if(addres !== 0x16){
							blue.showData.push({name:'TX:',value:converter.ab2hex(buffer)});
						}					
						if(blue.showData.length>8){
							blue.showData.splice(0,1)
						}
						if(test.type.includes(8)){
							global.timestamp = testFunc.formatTime();
							test.log.unshift({name:test.type.includes(4)?global.timestamp+' TX:':' TX:',value:test.type.includes(1)?converter.ab2hex(buffer):converter.ab2str(buffer)});
						}
						//buffer本身是arraybuffer（arraybuffer要转换为16进制）
						console.log('手机发送的数据',converter.ab2hex(buffer));	
					},
					success: (res) => {
						console.log(res,'writeBLECharacteristicValue ok')
						if(global.searchBaud){
							global.timeout2 = setTimeout(()=>{
								clearTimeout(global.timeout2)							
								global.writeOK = 0;
								resolve(1);
							},400)
						}
						// 操作之前先监听，保证第一时间获取数据（value就是特征值当前最新的值）
						blue.receiveData = [];					
						//监听低功耗蓝牙设备的特征值变化事件。必须先启用 notifyBLECharacteristicValueChange 接口才能接收到设备推送的 notification
						uni.onBLECharacteristicValueChange((characteristic) => {
							//console.log('触发监听(onBLECharacteristicValueChange)');
							console.log('手机接收的数据：',converter.ab2hex(characteristic.value));						
							clearTimeout(global.timeout2);
							global.writeOK = 0;
							if(test.type.includes(8)){
								global.timestamp = testFunc.formatTime();
								test.RXLength = test.RXLength + characteristic.value.byteLength
								test.log.unshift({name:test.type.includes(4)?global.timestamp+' RX:':' RX:',value:test.type.includes(2)?converter.ab2hex(characteristic.value):converter.ab2str(characteristic.value)});
							}						
							blue.receiveData = blue.receiveData.concat(Array.from(new Uint8Array(characteristic.value)))						
							if(blue.receiveData.length >= blue.resLength){
								blue.receiveData = new Uint8Array(blue.receiveData)							
								resolve(blue.receiveData);
								if(addres !== 0x16){
									blue.showData.push({name:'RX:',value:converter.ab2hex(blue.receiveData)});
								}
							}						
							if(blue.showData.length>8){									//显示区数据大于8条把前面数据删掉
								blue.showData.splice(0,1)
							}
						})					
					},
					fail: (err) => {
						global.writeOK = 0;
						console.log(err,'fail')					
						reject(err);
					}
				})
			})
		},
		write_ztble:(baudRate,checkout,stopBit)=>{					//蓝牙参数配置，封装promise，解决嵌套问题
			return new Promise((resolve,reject)=>{
				console.log('write_ztble')
				if(!blue.connected){
					uni.showToast({	title:'请先连接蓝牙',	icon:'none'})
					return
				}
				if(global.writeOK){						//确保一次收发数据完成
					global.timeout = setTimeout(()=>{//超时确保能进行下一次收发数据
						global.writeOK = 0
					},200)
					return
				}
				global.writeOK = 1
				clearTimeout(global.timeout);
				let sendData = [];
				let i = 0;			
				sendData[i++] = 0x06;
				sendData[i++] = 0x0A;
				let L8 = baudRate&0x000000ff;
				let L16 = (baudRate&0x0000ff00)>>8;
				let L24 = (baudRate&0x00ff0000)>>16;
				let L32 = (baudRate&0xff000000)>>24;
				sendData[i++] = L8;
				sendData[i++] = L16;
				sendData[i++] = L24;
				sendData[i++] = L32;
				sendData[i++] = 0x03;
				sendData[i++] = 0x0B;
				sendData[i++] = checkout;
				sendData[i++] = 0x03;
				sendData[i++] = 0x0C;
				sendData[i++] = stopBit;
				let buffer = new ArrayBuffer(sendData.length);
				let s_data = new Uint8Array(buffer);
				for(let i=0;i<sendData.length;i++){
					s_data[i] = sendData[i];
				}
				console.log(buffer,'buffer')
				blue.sendData = buffer;
				uni.writeBLECharacteristicValue({				//写
					deviceId: blue.deviceId,
					serviceId: blue.serviceId_ztble,
					characteristicId: blue.characteristicId_ztble_P,
					value: buffer,
					complete:(e)=>{
						if(test.type.includes(8)){
							global.timestamp = testFunc.formatTime();
							test.log.unshift({name:test.type.includes(4)?global.timestamp+' TX:':' TX:',value:test.type.includes(1)?converter.ab2hex(buffer):converter.ab2str(buffer)});
						}					
						blue.showData.push({name:'TX:',value:converter.ab2hex(buffer)});					
						if(blue.showData.length>8){
							blue.showData.splice(0,1)
						}					
						console.log('手机发送的数据',converter.ab2hex(buffer));	
					},
					success: (res) => {
						if(global.searchBaud){
							global.timeout2 = setTimeout(()=>{
								clearTimeout(global.timeout2)							
								global.writeOK = 0;
								resolve(1);
							},400)
						}
						//resolve(1);
						blue.receiveData = [];
						// 操作之前先监听，保证第一时间获取数据（value就是特征值当前最新的值）
						//监听低功耗蓝牙设备的特征值变化事件。必须先启用 notifyBLECharacteristicValueChange 接口才能接收到设备推送的 notification
						uni.onBLECharacteristicValueChange((characteristic) => {
							//console.log('触发监听(onBLECharacteristicValueChange)');
							console.log('手机接收的数据：',converter.ab2hex(characteristic.value));	
							if(test.type.includes(8)){
								global.timestamp = testFunc.formatTime();
								test.RXLength = test.RXLength + characteristic.value.byteLength
								test.log.unshift({name:test.type.includes(4)?global.timestamp+' RX:':' RX:',value:test.type.includes(2)?converter.ab2hex(characteristic.value):converter.ab2str(characteristic.value)});
							}
							clearTimeout(global.timeout2);
							global.writeOK = 0;						
							blue.receiveData = new Uint8Array(characteristic.value);
							resolve(blue.receiveData);
							blue.showData.push({name:'RX:',value:converter.ab2hex(blue.receiveData)});
							if(blue.showData.length>8){									//显示区数据大于8条把前面数据删掉
								blue.showData.splice(0,1)
							}
						})					
					},
					fail: (err) => {
						global.writeOK = 0;
						console.log(err,'fail')					
						reject(err);
					}
				})
			})
		}, */
		/* write_BLE:()=>{					//蓝牙参数配置，封装promise，解决嵌套问题
			return new Promise((resolve,reject)=>{
				if(!blue.connected){
					uni.showToast({	title:'请先连接蓝牙',	icon:'none'})
					return
				}
				if(global.writeOK){						//确保一次收发数据完成
					global.timeout = setTimeout(()=>{//超时确保能进行下一次收发数据
						global.writeOK = 0
					},200)
					return
				}
				global.writeOK = 1
				clearTimeout(global.timeout);
				let sendData = [];
				let i = 0;
				sendData[i++] = 0x06;
				sendData[i++] = 0x00;
				sendData[i++] = 0x09;
				sendData[i++] = 0x00;
				let L8 = serial.baudRate_BLE&0x000000ff;
				let L16 = (serial.baudRate_BLE&0x0000ff00)>>8;
				let L24 = (serial.baudRate_BLE&0x00ff0000)>>16;
				let L32 = (serial.baudRate_BLE&0xff000000)>>24;
				sendData[i++] = L8;
				sendData[i++] = L16;
				sendData[i++] = L24;
				sendData[i++] = L32;
				sendData[i++] = 8;
				sendData[i++] = serial.stopBit_BLE;
				sendData[i++] = serial.checkout_BLE;
				sendData[i++] = L8+L16+L24+L32+8+serial.stopBit_BLE+serial.checkout_BLE;
				let buffer = new ArrayBuffer(sendData.length);
				let s_data = new Uint8Array(buffer);
				for(let i=0;i<sendData.length;i++){
					s_data[i] = sendData[i];
				}
				console.log(buffer,'buffer')
				blue.sendData = buffer;
				uni.writeBLECharacteristicValue({				//写
					deviceId: blue.deviceId,
					serviceId: blue.serviceId_CH9141_P,
					characteristicId: blue.characteristicId_CH9141_P,
					value: buffer,
					success: (res) => {
						global.writeOK = 0;
						blue.showData.push({name:'TX:',value:converter.ab2hex(buffer)});
						if(blue.showData.length>8){
							blue.showData.splice(0,1)
						}
						//buffer本身是arraybuffer（arraybuffer要转换为16进制）
						console.log('手机发送的数据',converter.ab2hex(buffer));	
						resolve(1);
					},
					fail: (err) => {
						global.writeOK = 0;
						console.log(err,'fail')					
						reject(0);
					}
				})
			})
		}, */
		config_BLE:async()=>{						//多次配置蓝牙参数
			console.log('配置蓝牙参数')
			if(blue.advertisData == 'aa55'){				
				await bleService.write_ztble(serial.baudRate_BLE,serial.checkout_BLE,serial.stopBit_BLE);				
			}else{
				let i = 0;
				let timer = setInterval(async()=>{	
					await bleService.write_BLE();
					i++;					
					if(i>1){
						clearInterval(timer)
						console.log('clearInterval')
					}			
				},500)
			}		
		},
		openBluetoothAdapter:()=>{				//打开蓝牙		  
		  blue.devices=[]						//刷新蓝牙设备
		  uni.openBluetoothAdapter({
		    success: (res) => {
			  console.log("开启蓝牙适配器成功(openBluetoothAdapter success)", res);
			  uni.startBluetoothDevicesDiscovery({
			    allowDuplicatesKey: true, //允许重复上报同一个设备
			    success: (res) => {
			        console.log( "开始搜寻蓝牙设备成功(startBluetoothDevicesDiscovery success)", res);		  
			        uni.showLoading({
						title: "正在搜索设备",
					});		  
			  		uni.onBluetoothDeviceFound((res)=>{
						if(res){				
							uni.hideLoading({
								fail() {						
								}
							});				
						}
						res.devices.forEach(device=>{
						//过滤掉没有名字的设备
						if (!device.name && !device.localName) {
							return
						};	
						//这么操作是为了去除重复
						const foundDevices = blue.devices//将数据中的数组复制一份,利用动态绑定方式，不断复制最新的数组
						const idx = tool.inArray(foundDevices, 'deviceId', device.deviceId)
						if (idx === -1) {
							blue.devices.push(device);//数组里没有的的就向里面添加数据，保证没有重复[uni写法]
						}
						let arr = blue.devices.filter(item => converter.ab2hex(item.advertisData) == 'aa55')	//转能电子的设备
						let arr2 = blue.devices.filter(item => converter.ab2hex(item.advertisData) !== 'aa55')	//非转能电子的设备
						blue.devices = [...arr,...arr2];			//转能电子的设备排在前面
					})		
			  		});		  
			    },
			  });			  
		    },
		    fail: (res) => {
		      uni.showToast({
		        title: "请开启蓝牙",
		        icon: "none",
		      });          
		    },
		  });
		},		
		createBLEConnection:(e)=>{				//【点击某个蓝牙设备时】将目前你点击的设备作为对象e传递进来
			console.log('createBLEConnection',e)
			blue.closed=false
			const ds = e.currentTarget.dataset
			//将现在点击的设备id传递进去
			blue.deviceId = ds.deviceId
			//将设备名称也传递给全局变量
			blue.deviceName = ds.name
			let arr =  blue.devices.filter(item => item.deviceId == blue.deviceId)
			blue.advertisData = converter.ab2hex(arr[0].advertisData)
			console.log(arr,'createBLEConnection')
			if(blue.advertisData == 'aa55'){			
				console.log('ztble')
				blue.serviceId = blue.serviceId_ztble;
				blue.characteristicId = blue.characteristicId_ztble;
				blue.notifycharacteristicId = blue.notifycharacteristicId_ztble;
			}else if(blue.deviceName == 'HC-02'){
				console.log('HC-02')
				blue.serviceId = blue.serviceId_HC02;
				blue.characteristicId = blue.characteristicId_HC02;
				blue.notifycharacteristicId = blue.notifycharacteristicId_HC02;
			}else if(blue.deviceName == 'HC-04BLE'){
				console.log('HC-04BLE')
				blue.serviceId = blue.serviceId_HC04;
				blue.characteristicId = blue.characteristicId_HC04;
				blue.notifycharacteristicId = blue.notifycharacteristicId_HC04;
			}else if((blue.deviceName == 'CH9141BLE2U') || (blue.deviceName == 'ZTBLE')){
				console.log('CH9141BLE2U')
				blue.serviceId = blue.serviceId_CH9141;
				blue.characteristicId = blue.characteristicId_CH9141;
				blue.notifycharacteristicId = blue.notifycharacteristicId_CH9141;
			}
			global.showTitle = '建立连接失败'
			bleService.connectDevices()
		},
		createBLEReconnection:()=>{				//蓝牙断开重连
			closeRead();
			if(blue.closed || blue.connected){
				return
			}
			global.showTitle = '蓝牙重新连接'
			bleService.connectDevices()
		},
		connectDevices:()=>{
			uni.createBLEConnection({
				//这个deviceId不能删除，否则会报错【从这里往后要放一放】
				deviceId:blue.deviceId,			
				success: (res) => {					
					blue.connected=true,				
					uni.stopBluetoothDevicesDiscovery();			
					console.log('连接时获取设备id',blue.deviceId);
					if(blue.advertisData == 'aa55'){
						uni.setBLEMTU({
							deviceId:blue.deviceId,
							mtu:512,
							success: (res1) => {
								console.log('MTU = 512',res1)
							}
						})
					}else if(blue.deviceName == 'HC-04BLE'){
						uni.setBLEMTU({
							deviceId:blue.deviceId,
							mtu:185,
							success: (res1) => {
								console.log('MTU = 185',res1)
							}
						})
					}else if(blue.deviceName == 'HC-02'){
						uni.setBLEMTU({
							deviceId:blue.deviceId,
							mtu:64,
							success: (res1) => {
								console.log('MTU = 64',res1)
							}
						})
					}else if((blue.deviceName == 'CH9141BLE2U') || (blue.deviceName == 'ZTBLE')){
						uni.setBLEMTU({
							deviceId:blue.deviceId,
							mtu:131,
							success: (res1) => {
								console.log('MTU = 131',res1)
							}
						})
					}
					setTimeout(() => {
						bleService.getBLEDeviceServices();
					}, 1000);//这里必须要延迟才行这是一个bug
				},
				fail:(err)=>{
				  uni.showToast({
					title:global.showTitle,
					icon:'none'
				  })
				  return
				}
			})
		},
		onBLEConnectionStateChange:()=>{			//监听蓝牙连接状态
			uni.onBLEConnectionStateChange(function (res) {
			  // 该方法回调中可以用于处理连接意外断开等异常情况
			  blue.connected = res.connected;
			  console.log(res,'onBLEConnectionStateChange')		  
			  if(!blue.connected && !blue.closed){
				  global.writeOK = 0;
				  global.timer_R = setInterval(()=>{				
					bleService.createBLEReconnection();
				  	console.log('蓝牙重连')			  				
				  },3000)			  
			  }else{
				  clearInterval(global.timer_R)
			  }
			})
		},		
		getBLEDeviceServices:()=>{		//获取蓝牙设备所有服务（走到这一步证明已经找到服务）
			uni.getBLEDeviceServices({
				deviceId:blue.deviceId,
				success: (res) => {					
					uni.getBLEDeviceCharacteristics({					
					deviceId:blue.deviceId,
					serviceId:blue.serviceId,
					success: (res) => {						
						uni.notifyBLECharacteristicValueChange({
							deviceId:blue.deviceId,
							serviceId:blue.serviceId,
							characteristicId: blue.notifycharacteristicId,
							state: true,//是否启用notify通知
							success:(res)=>{
								console.log('通知启用(notifyBLECharacteristicValueChange)',res);
								/* uni.onBLECharacteristicValueChange((characteristic) => {									
									console.log(characteristic,'onBLECharacteristicValueChange')
									if(test.type.includes(8)){
										global.timestamp = testFunc.formatTime();
										test.RXLength = test.RXLength + characteristic.value.byteLength
										test.log.unshift({name:test.type.includes(4)?global.timestamp+' RX:':' RX:',value:test.type.includes(2)?converter.ab2hex(characteristic.value):converter.ab2str(characteristic.value)});
									}						
								}) */
								uni.onBLECharacteristicValueChange(bleService.handleReceivedData)
								if((blue.deviceName == 'CH9141BLE2U') || (blue.deviceName == 'ZTBLE')){
									bleService.config_BLE();
								}
							}
						})
						if(blue.advertisData == 'aa55'){
							uni.notifyBLECharacteristicValueChange({
								deviceId:blue.deviceId,
								serviceId:blue.serviceId,
								characteristicId: blue.notifycharacteristicId_ztble_P,
								state: true,//是否启用notify通知
								success:(res)=>{
									console.log('通知启用(notifyBLECharacteristicValueChange_ztble)',res);						
									bleService.config_BLE();
								}
							})
						}			
					},
					fail(res) {
						console.error('获取蓝牙设备特征值失败(getBLEDeviceCharacteristics)', res)
					}
					})
				},
				fail:(err)=>{
				  uni.showToast({
					  title:'获取服务失败',
					  icon:'none'
				  })
				  return
				}
		  })
		},		
		stopBluetoothDevicesDiscovery:()=>{		//停止蓝牙设备搜寻
		  uni.stopBluetoothDevicesDiscovery();
		  console.log("已停止蓝牙扫描(closeBluetoothAdapter)");
		  uni.showToast({
			title: "蓝牙搜索已停止",
			icon: "success",
		  });
		},
		closeBLEConnection:()=>{					//关闭蓝牙连接
			uni.closeBLEConnection({
			deviceId: blue.deviceId
			});
			blue.connected=false;
			blue.closed=true;		
			blue.chs=[];
			blue.canWrite=false;
			console.log("已关闭蓝牙连接(closeBLEConnection)");
			uni.showToast({
				title: "蓝牙连接已断开",
				icon: "success",
			});
		},
		handleReceivedData:(characteristic) => {
			try{
				console.log('手机接收的数据：',converter.ab2hex(characteristic.value));			
				// 如果有当前等待的请求，尝试匹配			
				blue.receiveData = [];
				if(blue.currentRequest){
					const {agreement,resolve,reject} = blue.currentRequest
					if(agreement == 'ZTBLE'){										//解析ZTBLE配置协议指令
						blue.receiveData = new Uint8Array(characteristic.value)
						resolve(blue.receiveData);
						blue.showData.push({name:'RX:',value:converter.ab2hex(blue.receiveData)});
						if(blue.showData.length>8){									//显示区数据大于8条把前面数据删掉
							blue.showData.splice(0,1)
						}
					}else if(agreement == 'CH9141'){										//解析CH9141配置协议指令
						resolve(1);
						/* blue.receiveData = new Uint8Array(characteristic.value)
						console.log('CH9141',blue.receiveData) */
						/* resolve(blue.receiveData);
						blue.showData.push({name:'RX:',value:converter.ab2hex(blue.receiveData)});
						if(blue.showData.length>8){									//显示区数据大于8条把前面数据删掉
							blue.showData.splice(0,1)
						} */
					}else if(agreement == 'modbus'){								//解析modbus协议指令
						const {addres,code} = blue.currentRequest
						blue.receiveData = blue.receiveData.concat(Array.from(new Uint8Array(characteristic.value)))						
						if(blue.receiveData.length >= blue.resLength){					
							blue.receiveData = new Uint8Array(blue.receiveData)
							if(addres !== 0x16){
								blue.showData.push({name:'RX:',value:converter.ab2hex(blue.receiveData)});
							}
							if(blue.showData.length>8){									//显示区数据大于8条把前面数据删掉
								blue.showData.splice(0,1)
							}
							// 检查地址和功能码是否匹配
							if(blue.receiveData[0] === serial.slave_id && blue.receiveData[1] === code){
								//匹配成功
								resolve(blue.receiveData);
								blue.currentRequest = null								
								bleService.processNextRequest()
								return
							}					
						}
					}								
				}
				// 未匹配到当前请求，可能是主动通知
				bleService.handleUnsolicitedResponse(new Uint8Array(characteristic.value))
			}catch(error){
				console.error('数据处理错误：',error)
			}
		},
		// 处理主动通知
		handleUnsolicitedResponse:(data) => {
			// 这里可以根据协议解析主动通知
			console.log("处理主动通知",data)
		},
		write:(code,addres,data,agreement = 'modbus',timeout = 1000) => {
			return new Promise((resolve, reject)=>{
				//创建请求对象
				const request = {				
					code,
					addres,
					data,
					agreement,
					resolve,
					reject,
					timestamp:Date.now()
				}
				//加入队列
				blue.requestQueue.push(request)
				// 如果没有正在处理的请求，立即处理
				if (!blue.currentRequest) {
				  bleService.processNextRequest()
				}
			})
		},
		write_ztble:(baudRate,checkout,stopBit,agreement = 'ZTBLE',timeout = 1000) => {
			return new Promise((resolve, reject)=>{
				//创建请求对象
				//let sendData = '060a80250000030b00030c01'		//配置波特率9600、1位停止位、1位数据位、无校验
				const request = {
					baudRate,
					checkout,					
					stopBit,
					agreement,
					resolve,
					reject,
					timestamp:Date.now()
				}
				//加入队列
				blue.requestQueue.push(request)
				// 如果没有正在处理的请求，立即处理
				if (!blue.currentRequest) {
				  bleService.processNextRequest()
				}
			})
		},
		write_BLE:(agreement = 'CH9141',timeout = 1000) => {
			return new Promise((resolve, reject)=>{
				//创建请求对象
				//let sendData = '060a80250000030b00030c01'		//配置波特率9600、1位停止位、1位数据位、无校验
				const request = {					
					agreement,
					resolve,
					reject,
					timestamp:Date.now()
				}
				//加入队列
				blue.requestQueue.push(request)
				// 如果没有正在处理的请求，立即处理
				if (!blue.currentRequest) {
				  bleService.processNextRequest()
				}
			})
		},
		//处理下一个请求
		processNextRequest:()=>{		
			if(blue.currentRequest || blue.requestQueue.length === 0)return
			// 取出队列中的第一个请求
			const request = blue.requestQueue.shift()
			blue.currentRequest = request
			//构建请求数据包
			if(request.agreement == 'ZTBLE'){
				let sendData = [];
				let i = 0;			
				sendData[i++] = 0x06;
				sendData[i++] = 0x0A;
				let L8 = request.baudRate&0x000000ff;
				let L16 = (request.baudRate&0x0000ff00)>>8;
				let L24 = (request.baudRate&0x00ff0000)>>16;
				let L32 = (request.baudRate&0xff000000)>>24;
				sendData[i++] = L8;
				sendData[i++] = L16;
				sendData[i++] = L24;
				sendData[i++] = L32;
				sendData[i++] = 0x03;
				sendData[i++] = 0x0B;
				sendData[i++] = request.checkout;
				sendData[i++] = 0x03;
				sendData[i++] = 0x0C;
				sendData[i++] = request.stopBit;
				let buffer = new ArrayBuffer(sendData.length);
				let s_data = new Uint8Array(buffer);
				for(let i=0;i<sendData.length;i++){
					s_data[i] = sendData[i];
				}
				console.log(buffer,'buffer')
				blue.sendData = buffer;
				const deviceId = blue.deviceId;
				const serviceId = blue.serviceId_ztble;
				const characteristicId = blue.characteristicId_ztble_P;				
				//const buffer = converter.hex2ab(request.data);
				uni.writeBLECharacteristicValue({				//写
					deviceId,
					serviceId,
					characteristicId,
					value: buffer,
					complete:()=>{
						blue.showData.push({name:'TX:',value:converter.ab2hex(buffer)});					
						if(blue.showData.length>8){
							blue.showData.splice(1,1)
						}
						//buffer本身是arraybuffer（arraybuffer要转换为16进制）
						console.log('手机发送的数据',converter.ab2hex(buffer));
					},
					success: (res) => {
						//blue.receiveData = [];
						// 操作之前先监听，保证第一时间获取数据（value就是特征值当前最新的值）
						//监听低功耗蓝牙设备的特征值变化事件。必须先启用 notifyBLECharacteristicValueChange 接口才能接收到设备推送的 notification
						request.timeoutId = setTimeout(()=>{
							if(blue.currentRequest === request){
								console.log(blue.currentRequest,'setTimeout')
								blue.currentRequest = null
								request.reject(new Error('请求超时'))
								bleService.processNextRequest()
							}
						},request.timeout || 1000)
					},
					fail: (err) => {
						console.log(err)						
						blue.currentRequest = null
						request.reject(err);
						bleService.processNextRequest()				
					}
				})
			}else if(request.agreement == 'CH9141'){
				let sendData = [];
				let i = 0;
				sendData[i++] = 0x06;
				sendData[i++] = 0x00;
				sendData[i++] = 0x09;
				sendData[i++] = 0x00;
				let L8 = serial.baudRate_BLE&0x000000ff;
				let L16 = (serial.baudRate_BLE&0x0000ff00)>>8;
				let L24 = (serial.baudRate_BLE&0x00ff0000)>>16;
				let L32 = (serial.baudRate_BLE&0xff000000)>>24;
				sendData[i++] = L8;
				sendData[i++] = L16;
				sendData[i++] = L24;
				sendData[i++] = L32;
				sendData[i++] = 8;
				sendData[i++] = serial.stopBit_BLE;
				sendData[i++] = serial.checkout_BLE;
				sendData[i++] = L8+L16+L24+L32+8+serial.stopBit_BLE+serial.checkout_BLE;
				let buffer = new ArrayBuffer(sendData.length);
				let s_data = new Uint8Array(buffer);
				for(let i=0;i<sendData.length;i++){
					s_data[i] = sendData[i];
				}
				console.log(buffer,'buffer')
				blue.sendData = buffer;
				const deviceId = blue.deviceId;
				const serviceId = blue.serviceId_CH9141_P;
				const characteristicId = blue.characteristicId_CH9141_P;
				//const buffer = converter.hex2ab(request.data);
				uni.writeBLECharacteristicValue({				//写
					deviceId,
					serviceId,
					characteristicId,
					value: buffer,
					complete:()=>{
						blue.showData.push({name:'TX:',value:converter.ab2hex(buffer)});					
						if(blue.showData.length>8){
							blue.showData.splice(1,1)
						}
						//buffer本身是arraybuffer（arraybuffer要转换为16进制）
						console.log('手机发送的数据',converter.ab2hex(buffer));
					},
					success: (res) => {
						//blue.receiveData = [];
						// 操作之前先监听，保证第一时间获取数据（value就是特征值当前最新的值）
						//监听低功耗蓝牙设备的特征值变化事件。必须先启用 notifyBLECharacteristicValueChange 接口才能接收到设备推送的 notification
						request.timeoutId = setTimeout(()=>{
							if(blue.currentRequest === request){
								console.log(blue.currentRequest,'setTimeout')
								blue.currentRequest = null
								request.reject(new Error('请求超时'))
								bleService.processNextRequest()
							}
						},request.timeout || 1000)
					},
					fail: (err) => {
						console.log(err)						
						blue.currentRequest = null
						request.reject(err);
						bleService.processNextRequest()				
					}
				})
			}else if(request.agreement == 'modbus'){			
				blue.resLength = 8;
				if(request.code == 0x03 || request.code == 0x04){
					blue.resLength = 5+2*Number(request.data);
				}			
				let sendData = [];
				let i = 0;
				sendData[i++] = serial.slave_id;
				sendData[i++] = request.code;
				sendData[i++] = request.addres>>8;
				sendData[i++] = request.addres;
				if (request.code == 0x10) {						//写多个寄存器
					sendData[i++] = request.data.length>>8;
					sendData[i++] = request.data.length;
					sendData[i++] = request.data.length*2;
					for(let j=0;j<request.data.length;j+2){
						sendData[i++] = request.data[j]>>8;
						sendData[i++] = request.data[j++]&0xff;
					}
				} else{									//读/写单个寄存器
					sendData[i++] = request.data>>8;
					sendData[i++] = request.data&0xff;
				}
				let crc = tool.getCRC16(sendData,sendData.length);	//CRC校验
				sendData[i++] = crc >> 8;
				sendData[i++] = crc & 0xff;
				let buffer = new ArrayBuffer(sendData.length)
				let s_data = new Uint8Array(buffer)
				for(let i=0;i<sendData.length;i++){
					s_data[i] = sendData[i];
				}
				blue.sendData = buffer;
				const deviceId = blue.deviceId;
				const serviceId = blue.serviceId;
				const characteristicId = blue.characteristicId;
				uni.writeBLECharacteristicValue({				//写
					deviceId,
					serviceId,
					characteristicId,
					value: buffer,
					complete:()=>{
						if(request.addres !== 0x16){
							blue.showData.push({name:'TX:',value:converter.ab2hex(buffer)});
						}					
						if(blue.showData.length>8){
							blue.showData.splice(1,1)
						}
						//buffer本身是arraybuffer（arraybuffer要转换为16进制）
						console.log('手机发送的数据',converter.ab2hex(buffer));
					},
					success: (res) => {
						//blue.receiveData = [];
						// 操作之前先监听，保证第一时间获取数据（value就是特征值当前最新的值）
						//监听低功耗蓝牙设备的特征值变化事件。必须先启用 notifyBLECharacteristicValueChange 接口才能接收到设备推送的 notification
						request.timeoutId = setTimeout(()=>{
							if(blue.currentRequest === request){
								console.log(blue.currentRequest,'setTimeout')
								blue.currentRequest = null
								request.reject(new Error('请求超时'))
								bleService.processNextRequest()
							}
						},request.timeout || 1000)
					},
					fail: (err) => {
						console.log(err)				
						/* if(err.errCode = 10006){
							createBLEReconnection();
							console.log('重连')
						} */
						blue.currentRequest = null
						request.reject(err);
						bleService.processNextRequest()				
					}
				})
			}		
			
		}
	}
	function copy(value){							//指令复制
		uni.setClipboardData({
			data:value,
			success: () => {
				uni.showToast({
					title: '复制成功'
				});
			}
		})
	}
</script>

<style scoped lang="scss">
@import '@/uni_modules/uni-scss/index.scss';
$mian-color: #007aff !default;
$uni-border-color: #EBEEF5 !default;
$uni-shadow-base: 0 0px 6px 1px rgba($color: #a5a5a5, $alpha: 0.2) !default;
page {
  color: #333;
}
.flex-center{
	display: flex;
	align-items: center;
	justify-content: space-around;	
}
.flex-row{
	display: flex;
	flex-direction: row;
	align-items: center;
}
.flex-column{
	display: flex;	
	flex-direction: column;	
}
.flex-column-reverse{
	display: flex;
	flex-direction: column-reverse;
}
.flex-1{
	flex: 1;
}
.width-0{
	width: 120rpx;
}
.width-1{
	width: 150rpx;
}
.width-2{
	width: 200rpx;
}
.width-3{
	width: 220rpx;
}
.width-4{
	width: 300rpx;
}
.text-center{
	text-align: center;
}
.height-0{
	height: 60rpx;
	line-height: 60rpx;	
}
.height-1{
	height: 950rpx;
}
.border-bottom {
	border-bottom: 2px solid #007aff;	
	color: #007AFF;
}
.background-color{
	background-color: #f5f5f5;
}
.device_list {
  height:380px;
  margin-top: 0;
  border: 1px solid #eee;
  border-radius: 5px;
  width: auto;  
}
.device_item {
  border-bottom: 1px solid #f5f5f5;
  padding: 10px;
  color: #666;
}
.device_item_hover {
  background-color: rgba(0, 0, 0, 0.1);
}
.card {
	margin: 5px;
	padding: 5px;
	background: white;
	border: 1px solid $uni-border-color;
	border-radius: 5px;
	box-shadow: $uni-shadow-base;
	font-size: 26rpx;
}
.card-radio{
	display: flex;
	flex-direction: row;	
	padding: 10rpx;	
}
.card-list-show-m{
	flex: 1;
	height: 42rpx;
	text-align: center;
	background-color: #f8f8f8;
	border-radius: 10rpx;
	margin: 0 8rpx;
}
.data_list {
  height:125px;
  margin:2px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 5px;
  width: auto;
}
.text-box {
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.divider{	
	height: 2rpx;
	background-color: #ddd;
}
.foot{
	font-size: 22rpx
}
.light-bulb {
  width: 40rpx;
  height: 40rpx;
  border-radius: 50%;
  background-color: #fff; /* 默认灰色（关灯） */
  border: 2rpx solid #666;  
  margin-right: 10rpx;  
}
.state-card{
	background-color: #aaffff;
	padding: 10rpx;
	margin: 10rpx;
	border-radius: 10rpx;
}
.light-red {
  background-color: #ff0000; /* 亮黄色（开灯） */  
}
.light-green {
  background-color: #00ff00; /* 亮黄色（开灯） */  
}
.light-yellow {
  background-color: #ffff00; /* 亮黄色（开灯） */  
}
.text-red{
	color: #ff0000;
}
.text-green{
	color: #00ff00;
}
</style>